LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rm and grep (https://www.linuxquestions.org/questions/linux-newbie-8/rm-and-grep-773371/)

TheGNUbie 12-03-2009 11:54 PM

rm and grep
 
if I wanted to recursively remove Thumbs.db files can I use rm with |grep?
ie rm -rf /mp3|grep Thumbs.db

Would this throw an error? or what would happen?

bret381 12-04-2009 12:22 AM

I believe what that would do is remove the folder /mp3 then try to search for thumbs.db inside the recently deleted folder mp3...Not what you are wanting.

Aquarius_Girl 12-04-2009 12:38 AM

You can do it simply like
Code:

rm -rf /mp3/Thumbs.db -i
. No need to use grep here. The above shown command does what u want !

And if u don't want to take any risk with 'rm' command u can attach '-i' at the end of the command. In that case it'll ask u before deleting anything !

pixellany 12-04-2009 06:46 AM

The pipe operator (|) is used to connect the output of one command to the input of another. In your example, "rm" does not produce any output, so there is nothing to pipe into grep.


All times are GMT -5. The time now is 05:37 AM.