Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

2 Answers 2

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

find -name "aname" -delete 

Btw.:

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
add comment

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

source: http://linuxcommando.blogspot.com/2007/10/find-xargs-pipe.html

share|improve this answer
3  
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
add comment

Your Answer

 
discard

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.