I want to move files in a directory that are not currently in use. I have a sense that some combination of lsof, find, and xargs could work but I can't quite get there. So far, I created the following command:
lsof mydir/*|awk '(NR>1){print $9}
This gives me a list of files that ARE being used. If I could just get a list of files that are NOT being used, then something like xargs could issue a mv on those files. I just can't seem to find an elegant way of doing this. Does anyone have any hints for me?
lsofoutput into a map, and then do the walk operation, excluding opened files, to build up the list of files to move. However I wonder why you can't just move all files in the first place? – Douglas Leeder Dec 7 '10 at 17:54ls, I'm trying write a bash script. – User1 Dec 7 '10 at 17:56