2つのパターン間の文字列を抽出して印刷します。

2つのパターン間の文字列を抽出して印刷します。

以下はファイルの内容です

SM Filesystems - ci240min;vlg00457.wdf.sap.corp;00205495930028250313;;Virtual_Gcp,Virtual,SISM_responsible,Linux_Suse,Linux,E2E_Services,Database,DLM;;;;0;warning;OK: all local filesystems are writeable OK: /var is mounted with correct options \nOK: /home is mounted with correct options \nOK: /opt/bmc mounted and writeable \nOK: /boot disk usage 18% of 250M with available size of 195 MB\nOK: / disk usage 69% of 7.9G with available size of 2522 MB\nOK: /var disk usage 31% of 2.0G with available size of 1406 MB\nOK: /opt disk usage 43% of 4.0G \nOK: /tmp disk usage 4% of 2.0G with available size of 1945 MB\nOK: Found no max. files in any monitored directory \nOK: /boot/ inode usage 1% \nOK: / inode usage 45% \nOK: /var/ inode usage 4% \nOK: /opt/ inode usage 4% \nOK: /tmp/ inode usage 1% \nOK: Initialised Physical disks are in use \nERROR: Disks partitions sde to be checked \n

「partitions」と「to」文字列の間にある単一vlg00457.wdf.sap.corpを使用して印刷する必要があります。今私は2人の他の人と一緒にいることができますsdeawkawk

cat bala.txt | grep -i "ERROR: Disks partitions" | tail -1 | awk -F ";" '{print $2}'
vlg00457.wdf.sap.corp


cat bala.txt | grep -i "ERROR: Disks partitions" | tail -1 | awk -F"partitions" '/partitions/{print $2}'
 sde to be checked \n

ベストアンサー1

使用sed:

$ grep "ERROR: Disks partitions" bala.txt |
    sed -E 's/(^.*ERROR: Disks partitions | to be checked.*$)//g'
sde

おすすめ記事