如何从bashshell运行Logparser
我在Windows box上 我打开git bash shell并运行 logparser从testFile.log-i:IISW3C-o:CSV中选择日期 这很有效 但是如果我用如何从bashshell运行Logparser,bash,sh,logparser,Bash,Sh,Logparser,我在Windows box上 我打开git bash shell并运行 logparser从testFile.log-i:IISW3C-o:CSV中选择日期 这很有效 但是如果我用 cmd_to_run='logparser "select date from testFile.log" -i:IISW3C -o:CSV' $cmd_to_run 这不起作用,我得到logparser错误: 错误:在查询后检测到额外的参数select 我只需要通过.sh脚本运行logparser。 您能帮忙吗?
cmd_to_run='logparser "select date from testFile.log" -i:IISW3C -o:CSV'
$cmd_to_run
这不起作用,我得到logparser错误:
错误:在查询后检测到额外的参数select
我只需要通过.sh脚本运行logparser。
您能帮忙吗?首先,为什么不直接运行它呢 转义查询中的空白,因为bash将其展开,并且您将位置参数提供给logparser,而不是保留的字符串。如果不起作用,请尝试评估 为了说明这一点,下面是一个与wc类似的示例:
$ wc -w <<< "select date from testFile.log"
4
$ cmd_to_run='wc -w <<< "select date from testFile.log"'
$ $cmd_to_run
wc: <<<: No such file or directory
wc: "select: No such file or directory
wc: date: No such file or directory
wc: from: No such file or directory
wc: testFile.log": No such file or directory
0 total
$ eval $cmd_to_run # quote as appropriate
4