在 Linux 中自动重复命令 [英] Repeat command automatically in Linux

查看:28
本文介绍了在 Linux 中自动重复命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Linux 命令行中是否可以每 n 秒重复一次命令?

Is it possible in Linux command line to have a command repeat every n seconds?

说,我有一个导入正在运行,我正在做

Say, I have an import running, and I am doing

ls -l

检查文件大小是否在增加.我想要一个命令让这个自动重复.

to check if the file size is increasing. I would like to have a command to have this repeat automatically.

推荐答案

每 5 秒观看一次 ...

Watch every 5 seconds ...

watch -n 5 ls -l

如果您希望对更改进行视觉确认,请在 ls 命令之前附加 --differences.

If you wish to have visual confirmation of changes, append --differences prior to the ls command.

根据 OSX 手册页,还有

According to the OSX man page, there's also

--cumulative 选项使突出显示粘性",呈现一个运行显示所有已更改的位置.-t或 --no-title 选项关闭显示间隔的标题,命令和当前时间显示在显示屏的顶部,以及跟随空行.

The --cumulative option makes highlighting "sticky", presenting a running display of all positions that have ever changed. The -t or --no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.

Linux/Unix 手册页可以在这里

Linux/Unix man page can be found here

这篇关于在 Linux 中自动重复命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆