Chinaunix

标题: watch 一个命令流的问题 [打印本页]

作者: mscnvs    时间: 2009-07-16 10:04
标题: watch 一个命令流的问题
我想用 watch 监控

find -type f -name "http*"|xargs cat|awk -F"\t" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5}' 这个命令流的输出

但是总是出错
请问应该怎么写才能正确运行呢?

谢谢~

Beaver1.jpg (5.21 KB, 下载次数: 9)

Beaver1.jpg

作者: streetboy85    时间: 2009-07-16 10:43
请给出错误提示
作者: mscnvs    时间: 2009-07-16 10:59
我用单引号把后面的命令括起来是这样的:

[root@localhost tmp]# watch -n 1 -d 'find -type f -name "*http*"|xargs cat|awk -F"\t" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5}''
awk: cmd. line:2: (END OF FILE)
awk: cmd. line:2: syntax error
xargs: cat: terminated by signal 13

Every 1.0s: find -type f -name "*http*"|xargs cat|awk -F"\t" {print \t\t\t\t}                                          Thu Jul 16 10:54:50 2009

                                                                                                                                         1

                                                                                                                                         2

awk: cmd. line:2: (END OF FILE)
awk: cmd. line:2: syntax error
xargs: cat: terminated by signal 13
awk: cmd. line:2: (END OF FILE)
awk: cmd. line:2: syntax error
xargs: cat: terminated by signal 13



我用双引号把后面的命令括起来是这样的:

[root@localhost tmp]# watch -n 1 -d "find -type f -name "*http*"|xargs cat|awk -F"\t" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5}'"
xargs: cat: terminated by signal 13

Every 1.0s: find -type f -name *http*|xargs cat|awk -Ft '{print tttt}'                                                 Thu Jul 16 10:56:58 2009

                                                                                                                                         9

                                                                                                                                      7:00

                                                                                                                                         1

                                                                                                                                         2

                                                                                                                                         3

                                                                                                                                         4

xargs: cat: terminated by signal 13
xargs: cat: terminated by signal 13
xargs: cat: terminated by signal 13
作者: streetboy85    时间: 2009-07-16 15:41
可以指令写到一个脚本里面,然后用watch执行这个指令




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2