awk出力の一部を読むには

awk出力の一部を読むには

変数を出力して新しいコマンドに入力しようとしています。

jira.sh --action createIssue --project "BLAH" --type "Incident" --summary 
"THIS IS A TEST" --components "BLA" --priority "BLAH"| awk '{print $2}'

出力をください。XY-1234ここに問題があります。

xxxxのISSUEセクションに渡す必要があります...ディスプレイスペースXY-1234に渡し、$ nameで変数を作成し、$ nameを渡しても機能しない方法は次のとおりです。$0/1/2name=$(awk '{print $2}')

jira.sh --action addAttachment --issue "xxxxx" --file "/var/log/blah.log"

ベストアンサー1

jira.sh/awk 出力を変数として取得する必要があります。

それではこれはどうですか?

JIRA=$(jira.sh --action createIssue \
               --project "BLAH" \
               --type "Incident" \
               --summary "THIS IS A TEST" \
               --components "BLA" \
               --priority "BLAH" | awk '{print $2}')

jira.sh --action addAttachment \
        --issue "$JIRA" \
        --file "/var/log/blah.log"

おすすめ記事