easy to loop command or watch on linux

easy to loop command or watch on linux

In Linux, it is possible to use commands repeatedly in a shell.

That’s watch command

watch can be set to repeat in seconds with the -n option.

watch -n 5 ls /var/log

If the above command is executed, the ls result is displayed on the screen every 5 seconds. You can use the options like -al to get a more detailed view.

If you want to make additional changes to grep, you can do it with quotes.

watch -n 5 'ls /var/log | grep apt'

In addition, it provides a -d option to highlight text when changes are made. However, it is not used much.

Facebook Comments

Leave A Reply

Detection ADBlockPlease, Disable or add to white list on our site.