Shell Script to delete files

Johnny Rosenberg gurus.knugum at gmail.com
Sat Apr 20 11:09:58 UTC 2013


2013/4/20 Johnny Rosenberg <gurus.knugum at gmail.com>:
> 2013/4/20 Akash Jain <akash.delhite at gmail.com>:
>> 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
>>   if [`lsof -n $f`]; then
>
> I think you need a space before and after [ and ] respectively:
> if [ `lsof -n $f` ]; then
>
> ”[” is a command and is a synonym for ”test”, therefore you need the spaces.

http://tldp.org/LDP/abs/html/special-chars.html#LEFTBRACKET


>
> Johnny Rosenberg
>
>>
>>        echo $f
>>   fi
>>
>> done
>>
>> Thanks !
>> Akash
>>
>>
>> --
>> ubuntu-users mailing list
>> ubuntu-users at lists.ubuntu.com
>> Modify settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>>




More information about the ubuntu-users mailing list