2

如果使用二元运算符,则内部具有多个条件的简单 awk。它吐出错误。请参阅下面的 O/P。

D:\Program Files\Veritas\NetBackup\bin>bpdbjobs -report -most_columns | awk '{FS=","; if ($2 == 0 || $11 > 0) printf "%s,%s,%s,%d,%s,%s,%s,%d:%d:%d,%d,%d\n", $7,$5,$6,$4,$8,strftime("%c",$9),strftime("%c", $11),$10/(60*60),$10%(60*60)/60,$10%60,$16,$15}' > c:\bpdbjobs_report_processed.csv
awk: cmd. line:2: {FS=","; if ($2 == 0
awk: cmd. line:2:                      ^ unexpected newline or end of string
'$11' is not recognized as an internal or external command,
operable program or batch file.

从输入数据中截取几行如下...

23123,0,0,,xxxxxEX-IS,Daily-Differen-Noon,xxxxxex, ,1374573600,0000007052,0000000000, ,1,,,,,0,,root,1,16,1,9999,root,xxx- abc-nbkp,2,2,0,0,0,0,0,23123,,,,,,,,,,,,,0,0,0,0,0,,0,,,,驱动器是在存储单元中使用 (xxx-abc-nbkp-hcart-robot-tld-0),
23122,17,3,0,,,,,1374566996,0000000035,1374567031,,1,,,,,100,7644,root,,,,,,xxx-abc-nbkp,,,,,,0,0 ,,,,,,,,,,,,,,,,,,,,,,,,,
23121,2,4,0,,,xxx-abc-BANCS1,xxx-abc-nbkp,1374557721,0000022931,0000000000,,1,,,,/backups/rpru/scripts/check_crs_listener.out,0,9628,root ,,,,90000,root,xxx-abc-nbkp,,,,0,10,0,0,,,,,,,,,,xxx-abc-nbkp,,,,1,1,,,, ,1,,,, ,
23120,0,1,,xxxxxEX-MB-BF,Daily,xxxxxex,xxx-abc-nbkp,1374555781,0000024871,0000000000,xxx-abc-nbkp-hcart-robot-tld-0,1,3,8579904,38000 ,/Microsoft Exchange 邮箱/Nisha Jayadas [njayadas]/信息存储顶部/收件箱/FW:2013 年 6 月 30 日的 xxxxx 最终报告\、2013 年 7 月 1 日和 2013 年 7 月 2 日,61,,root,0,16,4,0 ,other,xxx-abc-nbkp,3,3,0,0,55506,0,0,23120,346,,,,,,,,,,,0,0,0,0,0,0,xxxxxex_1374555781 ,1,,,0, ,
4

1 回答 1

2

假设您在 Windows 上,请更改命令行:

awk -F, "{if ($2 == 0 || $11 > 0) printf \"%s,%s,%s,%d,%s,%s,%s,%d:%d:%d,%d,%d\n\", $7,$5,$6,$4,$8,strftime(\"%c\",$9),strftime(\"%c\", $11),$10/(60*60),$10%(60*60)/60,$10%60,$16,$15}"
于 2013-07-23T12:12:04.527 回答