linux基本命令示例_带有示例Linux Watch命令教程

linux基本命令示例

linux基本命令示例

Some time generally long-running operations like copying disk need to track the change like disk usage or change of the size of the file. We generally run the same command again and again but this is a very cumbersome way yo see progress. Linux users created a “watch” application to make things better. When we use “watch” we can get change with specified interval times.

通常,某些长时间运行的操作(例如复制磁盘)需要跟踪更改(例如磁盘使用情况或文件大小的更改)。 我们通常会一次又一次地运行相同的命令,但这是您看到进度的非常麻烦的方式。 Linux用户创建了一个“监视”应用程序来使事情变得更好。 当我们使用“手表”时,我们可以在指定的间隔时间内进行更改。

句法 (Syntax)

We will use options to change behavior of the watch command. COMMAND is the command we want to run with given intervals.

我们将使用选项来更改watch命令的行为。 COMMAND是我们要以给定间隔运行的命令。

watch [OPTIONS] COMMAND

帮帮我 (Help)

We can print help information about the watch command with the -h option.

我们可以使用-h选项打印有关watch命令的帮助信息。

$ watch -h
Help
Help
帮帮我

只是看(Just Watch)

We will use watch command without providing any options. We will provide ls -lh command and run this command at 2 seconds interval. The default interval is 2 seconds.

我们将使用watch命令,而不提供任何选项。 我们将提供ls -lh命令,并以2秒的间隔运行该命令。 默认间隔为2秒。

$ watch ls -lh
Just Watch
Just Watch
只是看

As we can see from screenshot all files and folders are listed and will be refreshed in 2 seconds interval.

正如我们从屏幕快照中看到的,所有文件和文件夹都被列出,并且将在2秒的间隔内刷新。

退出或退出 (Exit or Quit)

While running watch it will not end automatically. We must kill the watch process if we want to end. The simple way to end watch is using the following shortcut.

跑步时, watch不会自动结束。 如果要结束,我们必须取消watch程序。 结束watch的简单方法是使用以下快捷方式。

CTRL+c

设定间隔 (Set Interval)

Default interval value for the watch is 2 seconds. In each interval provided command runs and the output is refreshed. We may need to change 2 seconds interval more suitable for our situation. -n option can be used to change the default interval. We change ls -lh command interval to 5 seconds in the following example.

手表的默认间隔值为2秒。 在提供的每个间隔中,将运行命令并刷新输出。 我们可能需要更改2秒间隔更适合我们的情况。 -n选项可用于更改默认间隔。 在以下示例中,我们将ls -lh命令间隔更改为5秒。

$ watch -n 5 ls -lh
Set Interval
Set Interval
设定间隔

删除标题(Remove Header)

We can remote the watch title so we just get command output if we want to use the output from different applications.

我们可以远程监视手表标题,因此,如果我们要使用来自不同应用程序的输出,则只获取命令输出。

$ watch -t ls -lh
Remove Header
Remove Header
删除标题

如有更改,请播放提示音(Play Beep If There Is Change)

As watch commands run provided command periodically. If there is no change the provided command provides 0 as output. If there is change there will be a non zero change which means there is a change. wait command can play a beep sound if the output is non-zero. We will provide the -b or --beep option.

当watch命令定期运行提供的命令时。 如果没有更改,提供的命令将提供0作为输出。 如果有变化,将有一个非零变化,这意味着有变化。 如果输出非零,则wait命令可以播放哔声。 我们将提供-b--beep选项。

$ watch -b ls /home/ismail
Play Beep If There Is Change
Play Beep If There Is Change
如有更改,请播放提示音
LEARN MORE  How To List, Set, Get Windows Environment Variables With Set Command In Command Line MS-DOS?
了解更多信息如何在命令行MS-DOS中使用Set命令列出,设置,获取Windows环境变量?

带有示例信息图Linux Watch命令教程 (Linux Watch Command Tutorial With Examples Infographic)

Linux Watch Command Tutorial With Examples Infographic

翻译自: https://www.poftut.com/linux-watch-command-tutorial-with-examples/

linux基本命令示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值