watch命令 定时执行一个命令,并将结果打印到屏幕

watch   [-dhvt]   [-n   <seconds>]   [--differences[=cumulative]]   [--help]  [--interval=<seconds>]

[--no-title] [--version] <command>


-d 高亮显示变化的字符。

-h 显示帮助

-v 显示版本

-t 显示标题

-n <seconds> 定时的时间间隔,默认是2秒。

--differences 和 -d 一样

--differences=cumulative 粘滞高亮显示变化的字符。

--help 和 -h 一样

--interval=<seconds> 和 -n <seconds> 一样


另外请注意,如果你的原始命令中包含管道,比如。

ps -ef|grep test|grep -v grep        # 查看包含test的进程信息。

使用 watch的时候,需要加上 单引号

watch 'ps -ef|grep test|grep -v grep'






你可能感兴趣的:(bash)