I am trying to use the watch command to see the latest file. It is showing the file but how do I switch to the latest one when an even newer file is created?
The files are pictures so I am opening them with an image viewer
here's what I tried
watch -n 0.1 ls /home/titan/mnt
but it doesn't work because I just need one file and basically the lastest file and store that file name and open it with an image viewer.
It is not clear to me why you want to use the
watch
command. Alsols
is not the best choice here for many reasons.If all you want is to watch for when a new file is created in
/home/titan/mnt
and open that file in an image viewer, then installinotify-tools
like so:and use it in a bash script like so: