以下是要求。
使用bash脚本如何在csv文件上从linux服务器实现上述条件。
我尝试了以下内容:
cat csv_report.csv | awk '!/SET SNAP_ID/' | awk '!/Shadow/'
cat csv_report.csv | awk -F'=' '!/^$/{arr[$1]=$2}END{for (x in arr) {print x"="arr[x]}}'
cat csv_report.csv | grep "Failed"
csv_report.csv如下 -
Client Name Friday 08/8 Saturday 08/9 Sunday 08/10 Monday 08/11 Tuesday 08/12 Wednesday 08/13 Thursday 08/14 Friday 08/15 elgar.ppp->E:\ Failed Full FS_Win_801_Thu_B Full_Backup 0B;
gershwin.ppp->D:\ Failed Full FS_Win_801_Thu_B Full_Backup 0B;
mozart.ppp->D:\ Successful Full FS_Win_801_Fri_B Synthetic_Full 0B; Failed Full FS_Win_801_Fri_B Full_Backup 0B;
nicklaus.ppp->C:\ Successful Full FS_Win_801_Fri_B Synthetic_Full 0B; nicklaus.ppp->D:\ Successful Full FS_Win_801_Fri_B Synthetic_Full 0B; Failed Full FS_Win_801_Fri_B Full_Backup 0B; Failed Full FS_Win_801_Fri_B Synthetic_Full 0B; samgdef00.ppp->C:\ Successful Full FS_Win_801_Thu_B Full_Backup 0B; Failed Full FS_Win_801_Thu_B Full_Backup 0B;
samgdef00.ppp->E:\ Failed Full FS_Win_801_Thu_B Full_Backup 0B;
samgdef06.ppp->C:\ Successful Full FS_Win_801_Fri_B Synthetic_Full 0B; Failed Full FS_Win_801_Fri_B Synthetic_Full 0B;
答案 0 :(得分:0)
awk -v FS=';' '{if(NF>2&&$0~/Failed/&&$0~!/SET SNAP_ID/&&$0~!/Shadow/)print $0}' file