Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list of directories that I want to go into and delete particular files. For example, the directory names I have are as below:


Each of these directories has 4 files in them and the file names are:


I want to write a script that would go into each of these directories and delete:


Can someone please help me with that?

share|improve this question
man find, read the exec and name parts – dawud Sep 18 '13 at 7:15

You don't have to go into each directory separately. Just pass the file names you want deleted to find and delete them with the -delete option.

find . -type f \
\( -name 'dealer_score_01.txt' -or -name 'dealer_score_03.txt' \) -delete

Leave out -delete to make sure you delete the right files.

share|improve this answer
Hi Slhck, Thanks for the reply. I want to delete these files only in certain directories.If i use the command above, it would delete these files in all the directories. Is there any way to delete only in few directories by specifying the directory names in which i want these files to be deleted? – user255223 Sep 18 '13 at 8:55
You can just specify the directory names instead of . for the find command. For example find 091513 090213 -type f … – slhck Sep 18 '13 at 9:08
How many directories can I specify at a time in the find command? I have more than 200 directories that I want to do this with... – user255223 Sep 18 '13 at 12:08
You can specify as many as you want. How do you get the list of directories in the first place? In a text file? From a command? Maybe you should clarify your question and tell us what exactly you need to do. – slhck Sep 18 '13 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .