Results 1 to 1 of 1
I have a script that checks for the existence of some specific files on a network drive using bash's "if [ -s ... ]" inside of a loop. When the ...
- 02-03-2010 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 12
Under-the-hood of the ls command
I have a script that checks for the existence of some specific files on a network drive using bash's "if [ -s ... ]" inside of a loop. When the files are found, the loop terminates and the script continues on. I noticed that the if-statement was failing to recognize the files existed immediately after the files were created. Eventually the if-statement would pass, but only after causing the loop to hang for several seconds.
During my investigation, I noticed that simply putting an "ls" command right before the if-statement caused the files to be recognized immediately. I'm assuming ls has some under-the-hood function that forces the network file handler to notice any new files that were just created. Anyone know what functionality that is? For now, I literally put "ls > /dev/null" into my script, and that works great, but I was hoping to call something a little more elegant.
Operating system is RedHat 5.
Thanks!
-Dan


Reply With Quote