Shell scripts

Files opened

To know if a file is opened by some process without lsof:

ls -l /proc/*/fd | grep FILENAME

Infinite loop

To do some stuff in an infinite shell loop:

The following code will print the date each second.

while :; do echo `date`; sleep 1; done
while :; do echo `ls -l /proc/*/fd | grep FILENAME -B5`; sleep 0.5; done