Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 installed (compiled) emerald. The command make uninstall didn't work (there is no makefile as it is just a script). So I decided to remove the file manually. But there were a lot of files.

I've tried some things but it didn't work. So I came here to ask for some advice.

  • Is there a command with ls -R | grep blabla* that I can add to display file directory (it only displays filename)
  • Is there a true ls -R | grep bla* | rm ?
share|improve this question

If 'aname' shall be the starting part of the filename, it would be, from the current directory:

find -name "aname" -delete 


grep "bla"* somewhere

is almost always false, since grep already makes partial matches, which means, it finds bla, blafasel and xybla with simply

grep bla somewhere

Deleted older part of answer, because of misunderstanding:

From the current directory, if you look for the word 'aname' in all files, you can just use:

find -exec grep "aname" {} ";" -delete 

share|improve this answer
Thanks for your help, but i didn't help me. I'm looking for a command that recursively find "myfilename*" into child folders. Just like 'ls -R | grep name*'... and delete them. – Cyclic Jan 17 '12 at 12:35
Ok it's good, i didn't notice that find recursively look into directory... Case resolved ;) thanks. I was just looking for : sudo find -name bla* -delete; :D so simple – Cyclic Jan 17 '12 at 12:45
@Cyclic: Don't forget to mask "bla*" with quotes; else it won't work. May I ask you to upvote helpful posts and to accept one of the helpful answers? (clicking the ^ signs before the answers and the symbol, similar to √ ) – user unknown Jan 17 '12 at 13:19

What you are looking for is a combination of xargs, find, and rm.

find will make a list of all the files matching your conditions, and then write them (null terminated) to stdout, which will be piped to xargs. xargs will take the null terminated strings and use them as arguments to rm.

find -L /path/to/dir -name "*name*" -print0 |xargs -0 -r  rm


share|improve this answer
The -delete find action could be of help. – enzotib Jan 17 '12 at 6:46
I can, but if the OP is looking for a general solution that can be used with more than just rm then he should look into this form. – Huckle Jan 18 '12 at 3:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.