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 want to delete a specific config file for Awstats for every user on the box. What is the best way to delete them, and possibly, in one line?

All the files are under /home and have this structure:



Some /home/{username}/domains/ folders have multiple domain subfolders.

share|improve this question
up vote 1 down vote accepted

Have you tried

rm /home/*/domains/*/public_html/awstats/.data/awstats.*.conf


Warning: if there is a file whose name is something like


i.e., the two occurrences of {domain1} don’t match, then the above command will delete it, too.  Is that a problem?

P.S. Unless verifying that the two occurrences of {domain1} match is what you’re asking about, or there’s something else that I’m missing, this question is not about regular expressions (regexs).  When *, ?, and [ (with a matching ]) are used on the shell command line, they are called wildcards.

share|improve this answer
Clearly I was thinking way too difficult with regular expressions and xargs! I haven't tried just using *'s in the command, but it seemed to work just fine. You saved me a lot of time. – lemimique Jan 4 '13 at 11:12
Glad to help. May I draw your attention to the How do I ask questions? section of the Super User FAQ (Frequently Asked Questions) –– “When you have decided which answer is the most helpful to you, mark it as the accepted answer by clicking on the check box outline to the left of the answer.” If you do that, we both benefit. After you have earned some reputation, you can also vote up helpful answers by clicking the upward pointing arrow to the left of the answer. – Scott Jan 4 '13 at 22:41

In /home run the following command

find . -name 'awstats*conf' | xargs rm

Before piping the result to xargs run the find . -name 'awstas*.conf by itself to verify that it lists only the files you want to remove. Pipe to xargs rm only after you confirm th is.

The find when used as shown above will recursively look for files that match the regex specified. For more information check the man pages for find and xargs.

share|improve this answer

You must log in to answer this question.

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