아래는 파일 내용입니다
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
을 사용하여 인쇄해야 합니다 . 이제 나는 두 명의 다른 사람과 함께 있을 수 있다sde
awk
awk
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
답변2
Perl을 사용하는 것은 매우 쉽습니다:
$ perl -F\; -lane '/partitions (\S+)/ and print "$F[1]\t$1"' bala.txt