http://beerpla.net/2007/08/04/watch-a-useful-linux-command-you-may-have-never-heard-of/
How many times did I want to watch a directory waiting for a file to appear in it? Constant ls, for example, quickly got boring. A quick Perl script that would reload ls every 5 seconds… yeah it works but it takes a while to type up, and often enough I'm too lazy for that. And then I found 'watch' – a utility that comes with most *nix distros. Look at this beauty [man watch]:
NAME
watch – execute a program periodically, showing output fullscreen
SYNOPSIS
watch [-dhvt] [-n ] [--differences[=cumulative]] [--help]
[--interval=] [--no-title] [--version]
DESCRIPTION
watch runs command repeatedly, displaying its output (the first screen
full). This allows you to watch the program output change over time.
By default, the program is run every 2 seconds; use -n or –interval to
specify a different interval.
The -d or –differences flag will highlight the differences between
successive updates. 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.
watch will run until interrupted.
NOTE
Note that command is given to "sh -c" which means that you may need to
use extra quoting to get the desired effect.
Note that POSIX option processing is used (i.e., option processing
stops at the first non-option argument). This means that flags after
command don't get interpreted by watch itself.
EXAMPLES
To watch for mail, you might do
watch -n 60 from
To watch the contents of a directory change, you could use
watch -d ls -l
If you're only interested in files owned by user joe, you might use
watch -d 'ls -l | fgrep joe'
To see the effects of quoting, try these out
watch echo $$
watch echo '$$'
watch echo "'"'$$'"'"
You can watch for your administrator to install the latest kernel with
watch uname -r
(Just kidding.)
分享到:
相关推荐
The complete guide to SUSE Linux - includes everything you need to take advantage of this powerful ... so you’ll have everything you need to get a Linux system up and running.,解压密码 share.weimo.info
It shows how one of the world’s top Perl authorities brings the language to bear on problems that require communication among computers, showing that you may not have to resort to Java as soon as you...
八年级Unit5 Do you want to watch a game show练习题及答案12.doc
Advice & Techniques from 5 Top Professionals gives you the base-knowledge and valuable secrets you'll need for your own projects from a core team of successful, experienced Apple Watch app-...
By the end of this book, you will have a good understanding of how to develop apps for the Apple Watch platform, and synchronize data using iCloud between the wearable and the iOS device. What You ...
这篇文档是针对八年级英语学习的一份练习题,主要涵盖了词汇、语法和句型的应用,旨在帮助学生巩固Unit5 "Do you want to watch a game show?" 的相关知识。以下是题目中涉及的一些关键知识点: 1. **词汇应用**: ...
Advice & Techniques from 5 Top Professionals gives you the base-knowledge and valuable secrets you'll need for your own projects from a core team of successful, experienced Apple Watch app-...
标题“watch the meteor shower with you”可能并非一个典型的IT主题,但考虑到标签中提到了“源码”和“工具”,我们可以推测这篇博文可能是关于一种编程工具或者代码实践的分享。由于描述部分是“NULL”,没有提供...
You've got a great idea for an Apple Watch app. But how do you get your app from idea to wrist? This book shows you how to make native watchOS apps for Apple's most personal device yet. You'll learn ...
Beginning Ubuntu Linux is split into seven parts, each of which contains chapters about a certain aspect of Ubuntu use. These parts can be read in sequence, or you can dip in and out of them at will. ...
Beginning Ubuntu Linux is split into seven parts, each of which contains chapters about a certain aspect of Ubuntu use. These parts can be read in sequence, or you can dip in and out of them at will. ...
今天,我们将详细介绍如何在 Linux 和 Windows 平台上安装 OpenCV 3.X,并且介绍 ImageWatch 插件的使用。 安装 OpenCV 3.X ### Linux 平台 在 Linux 平台上安装 OpenCV 3.X 需要 several 步骤: 1. 下载 OpenCV...
Master Python and become a programmer-even if you never thought you could! This breakthrough book and CD can help practically anyone get started in programming. It's called 'The Hard Way,' but it's ...
- `Do you have a watch?`: 你有手表吗? - `I don’t have a ping-pong ball.`: 我没有乒乓球。 - `Do you have a TV?`: 你有电视吗? - `Yes, I do. / No, I don’t.`: 对常用问答的肯定和否定回答。 - `Does...
【陕西省龙凤培训学校2013年中考英语复习资料】第五讲《Do you have a soccer ball》聚焦于初中英语的重点语法和句型,主要针对人教新目标版教材。本讲内容涵盖了一般现在时的用法,包括肯定句、否定句、疑问句以及...
cloudwatch-mon-scripts-python, 用于CloudWatch的Linux监视脚本 cloudwatch-mon-scripts-python 用于 AWS CloudWatch服务的Linux监视器脚本。最初,这个项目被创建,因为最初的AWS监控脚本在大约5 个月内缺乏对 eu-...
- 如 "I have a ping-pang ball." 的疑问句是 "Do you have a ping-pang ball?",肯定回答 "Yes, I do.",否定回答 "No, I don't." - 例如 "She has a soccer ball." 的疑问句是 "Does she have a soccer ball?",...
这篇文档是针对七年级上册英语课程Unit 5 "Do you have a soccer ball" 的一组精选练习题及答案,旨在帮助学生巩固与体育器材相关的词汇和一般疑问句的使用。这个单元的学习重点在于掌握与运动相关的一系列动词、...
Chapter 1, Principles of Software Architecture, introduces the topic of software architecture, giving you a brief on architectural quality attributes and the general principles behind them. This will ...