必要な部品のみを購入してください[閉じる]

必要な部品のみを購入してください[閉じる]

次の文字列があります。

**XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12" FCP_USERID=5667 FCP_USERNAME="SRI" FCP_PRINTER="noprint" FCP_SAVE_OUT=Y FCP_NUM_COPIES=1 "9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv" "/tmp_mnt2/attachments" "[email protected]" "This is the subject for the mail" "PFA for the list of Invoices that are stuck in workflow."**

単に次の文字列を変数として抽出します。

メールの件名です

今回も、次の文字列を別の変数に抽出してください。 PFAは、ワークフローに停滞した請求書のリストを表示するために使用されます。

常に同じではありません。文字列は、ユーザーが入力する内容によって異なります。

UNIXコマンドを使用してこれらの文字列のみを取得する方法を理解するのに役立つ人はいますか?

ありがとう、ボミ

ベストアンサー1

フィールドの数と順序、およびフィールドに含まれる引用符を決定したら、次を使用してcut -d\"必須フィールドを取得できます。

echo 'XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12" FCP_USERID=5667 FCP_USERNAME="SRI" FCP_PRINTER="noprint" FCP_SAVE_OUT=Y FCP_NUM_COPIES=1 "9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv" "/tmp_mnt2/attachments" "[email protected]" "This is the subject for the mail" "PFA for the list of Invoices that are stuck in workflow."' \
| cut -f14 -d\"
This is the subject for the mail

echo 'XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12" FCP_USERID=5667 FCP_USERNAME="SRI" FCP_PRINTER="noprint" FCP_SAVE_OUT=Y FCP_NUM_COPIES=1 "9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv" "/tmp_mnt2/attachments" "[email protected]" "This is the subject for the mail" "PFA for the list of Invoices that are stuck in workflow."' \
| cut -f16 -d\"
PFA for the list of Invoices that are stuck in workflow.

awkまたは、最後の2つのフィールドをインポートする必要がある場合は、次の方法を使用する方が良いかもしれません。

echo 'XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12" FCP_USERID=5667 FCP_USERNAME="SRI" FCP_PRINTER="noprint" FCP_SAVE_OUT=Y FCP_NUM_COPIES=1 "9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv" "/tmp_mnt2/attachments" "[email protected]" "This is the subject for the mail" "PFA for the list of Invoices that are stuck in workflow."' \
| awk -F\" '{ print $(NF-3) }'
This is the subject for the mail

おすすめ記事