I have a folder which files are copied to it like /home/my/. I want to run a command which shows number of files inside it in real time like what tail -f do with file contents. I know I should run ls *|wc -l to count files but I don't know how to do it for monitoring and keep it running.

  • @txtechhelp please post it as answer – VSB Apr 18 '16 at 9:58

If you have the watch command available on your distribution, you can run it like this:

watch -n 1 "ls /home/my"

This will run the ls /home/my command every n seconds (1 in this example) and will display the output to the screen.

Hope that can help.


Without watch you can try:

while sleep 1 ; do ls /home/my ; done

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.