Wednesday, August 17, 2011

Watch , Command to learn

Sometime there is need to watch a directory for certain file, i mean you want to keep watch on directory. Following command can serve your purpose

root#watch -d ls -l

Above command will update screen after every 2 second (Default is 2 sec) and present you with the difference (-d option).

If you want to monitor network connection update using watch command you can use in following way

root#watch -d 'netstat -an'

Watch command allow you to watch program output changes over time , by default that time is 2 second but you change that time using -n option.use -d option if you want to changes in successive update but if you want to see cumulative changes use -c option.