비지박스에 -P 옵션을 사용한 Grep

비지박스에 -P 옵션을 사용한 Grep

-P이미지가 있는 kubernetes 포드 내부의 BusyBox v1.31.1() 다중 호출 바이너리에서 옵션을 사용하여 grep 명령을 실행하고 싶습니다.curlimages/curl:7.75.0

curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$CFZONE_NAME"\
-H "X-Auth-Email: $CFUSER"\ 
-H "X-Auth-Key: $CFKEY" \
-H "Content-Type: application/json" \
| grep -Po '(?<="id":")[^"]*' \ # <- This is the culprit 
| head -1 
    
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$CFZONE_ID/dns_records?Name=$CFRECORD_NAME" \
-H "X-Auth-Email: $CFUSER" \
-H "X-Auth-Key: $CFKEY" \
-H "Content-Type: application/json"\
| grep -Po '(?<="id":")[^"]*'\ # <- This is the culprit
| head -1 

안타깝게도 이 서비스 -P는 제공되지 않습니다

grep: unrecognized option: P
BusyBox v1.31.1 () multi-call binary.


  Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
[...]


이 문제를 어떻게 해결할 수 있나요?

답변1

grep와 함께 사용할 수 있나요 cut?

grep -o '"id":"[^"]*' | cut -f4- -d\"

관련 정보