Monday, April 18, 2011

Deleting files from a directory.

On a linux shell deleting files is quite straightforward as it is expected just do rm fileName..

And if you have group of files which has a particular pattern and if you want to delete them, you do rm * < pattern >. But what do you do if you want to retain files with a particular patter and remove all other files in that directory.. This happens to me when I run some code for my work. My folder gets completely loaded with lot of log and tmp files which are produced by the main program. So how do I remove them ?

On a zshell its quite easy.. Say if you want to retain the files starting with the name mypetfile.

just do rm ^mypetfile*..

all the files which are not starting with the mypetfile is gone !!!

No comments:

Post a Comment