Shell Script to delete files

Joe Nyland lists at
Sat Apr 20 10:43:53 UTC 2013

On 20 Apr 2013, at 10:31, Nils Kassube <kassube at> wrote:

> Akash Jain wrote:
>> My aim is to delete more than 5 days old files which are no longer
>> used by any process. As a starter I have written following script,
>> but it does not work, says line 10 command not found.
>> HOME=~/var
>> cd $HOME
>> for  f in  `find . -type f`;  do
> It isn't clear where your script starts, so it is difficult to guess 
> which line the shell doesn't like. But I would suggest to carefully 
> check the line above.
> Nils


The following runs with no issues here:


cd $HOME

for f in `find . -type f`; do
  if [[ `lsof -n $f` ]]; then
       echo $f

Hope this helps.


More information about the ubuntu-users mailing list