Hi Guys,
I am new to unix
I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions
( like .ksh, .ch, ..............)
Thanks
Hi Guys,
I am new to unix
I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions
( like .ksh, .ch, ..............)
Thanks
From the man find (linux) manpage:
cd directory
find . -path ./somedir -prune -o -path ./anotherdir -prune -o -path ./moredir -prune -o -type f ! -name '*.ksh' ! -name '*.ch' -mtime +7 -exec rm {} \;
You might want save the list of files first, and them delete them after inspecting the list of files to be deleted ... just to be sure::
cd directory
find . findoptions -print > listfile
view listfile
xargs rm < listfile