If statement 带有多个条件的awk if抛出错误

If statement 带有多个条件的awk if抛出错误,if-statement,awk,conditional-statements,If Statement,Awk,Conditional Statements,简单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

简单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,,,,Drives are in use in storage unit (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 Mailboxes/Nisha Jayadas [njayadas]/Top of Information Store/Inbox/FW: xxxxx Final Report for 30 Jun 2013\, 01 Jul 2013 and 02 Jul 2013 ,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, , 存储单元(xxx-abc-nbkp-hcart-robot-tld-0)中正在使用驱动器, 这句话的意思是:1、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、,,,,,,,,,,,,,,,,,,,,,,,, 23121,2,4,0,,,xxx-abc-BANCS1,xxx-abc-nbkp,1374557721000022931000000,,,1,,,备份/rpru/scripts/check_-crs_-listener.out,09628,root,,,,,,90000,root,xxx-abc-nbkp,,,,,,,,,,,,,,,,,,,,,,,,,xxx-abc-nbkp,,,,,,,,1,1,,,, 23120,0,1,xxxxx EX-MB-BF,Daily,xxxxx EX,xxx abc nbkp,13745557810000024870000000,xxx-abc-nbkp-hcart-robot-tld-0,138579043800,/Microsoft Exchange Mailboxes/Nisha Jayadas[njayadas]/Top of Information Store/Inbox/FW:xxxxx 2013年6月30日、2013年7月1日和2013年7月2日的最终报告,61,root,0,16,4,0,other,xxx abc nbkp,3,3,0,055506,0,023120346,,,,,,,0,0,0,0,XXXXX Ex_1374555781,1,,,0,
假设您在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}"

您可能需要将
if
条件包装在
{}
中。所以它应该是
FS=“,”;{if…
感谢您的回复。D:\Program Files\Veritas\NetBackup\bin>bpdbjobs-report-大多数列{awk'{FS=”,“{if($2==0}$11>0)printf”%s、%s、%s、%D、%s、%s、%D:%D、%D、%D\n、$7、$5、$6、$4、$8、$strftime($c、$9)、strftime($c、$11)、$10/(60),$10%$60)/60、$60、$16、$15}'>c:\bpdbjobs_report_processed.csv awk:cmd.line:2:{FS=“,”;{if($2==0 awk:cmd.line:2:^意外换行符或字符串结尾“$11”未被识别为内部或外部命令、可操作程序或批处理文件。然后,您最好发布一些输入数据,以便我们检查。请格式化数据以提高可读性。在Windows中,您需要的是
Windows引号
,而不是bash/shell.captcha,你的回答似乎在引导我找到答案。使用Cygwin终端代替Windows CMD。它似乎工作正常。让我仔细检查一下。在
Cygwin
中,引用与bash/shell中的引用相同。但是错误消息
不被识别为内部或外部命令、可操作程序或批处理文件。
Windows,而不是Cygwin。