LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2009, 12:54 AM   #1
TheGNUbie
LQ Newbie
 
Registered: Mar 2007
Posts: 12

Rep: Reputation: 0
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?
 
Old 12-04-2009, 01:22 AM   #2
bret381
Member
 
Registered: Nov 2009
Location: Alabama
Distribution: Arch x86_64
Posts: 650

Rep: Reputation: 78
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.
 
1 members found this post helpful.
Old 12-04-2009, 01:38 AM   #3
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
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 !

Last edited by TheIndependentAquarius; 12-04-2009 at 01:47 AM.
 
Old 12-04-2009, 07:46 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 08:12 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration