shell script to search for files of specific extension and delete them all
Hi i want such a shell script or single line command to delete all the files with extension specified in script
i have bash !! ex... delete all files of extension .obj thanks in adv |
See
Code:
man find |
i used locate to find files of specific extension , plz tell me how to delete them ??
|
Pipe it to rm.
|
i dont know how to pipe ,plz give me code !!
|
Quote:
|
hi
suppose u want to find all the files with the extension .jpg in / # find / -name *.jpg | rm -rf hope this might help u if any errors please do correct me |
Come on, people.. let's not joke with the remove command! You cannot pipe the result of find or any other command directly to the standard input of rm, since the files to remove have to be passed as arguments. The rm command reserves the standard input for user interaction. Instead, let's wait the OP follows the TB0ne's advice and elaborates something for which we could really give help!
|
Quote:
If the file list didn't have spaces, he could pipe it into Code:
xargs /bin/rm |
Command to delete all files with .obj extension (from current directory):
Code:
find . -type f -name "*.obj" -print0 | xargs -0 -r rm -type f (only list standard files, not directories, devices, pipes etc) -print0 | xargs -0 (use null to seperate list of files to allow for spaces in file/directory names). Note character in flags is a numeric zero -r don't call rm if input is empty (i.e. no files were found) |
Quote:
|
Quote:
|
This command will search recursively starting at the directory given in /path/to/search/. Every file who's name ends in .jpg will be permanently and irrevocably erased. The deletion is done silently, so don't expect to be told what was deleted. Don't do this unless you are perfectly damn certain it is what you want.
Code:
find /path/to/search/ -type f -name '*.jpg' -delete Code:
man find Code:
info find http://www.gnu.org/software/findutil...tml/index.html |
All times are GMT -5. The time now is 12:29 AM. |