Find Command: Part III & remove grep from grep

Posted by Ameya Pandit on June 12th, 2007 filed in Tips & Trix, linux

Lets take the example first to clear the concept of “Removing Grep from Grep”. You want to search all those processes for APACHE. You enter the command as below for the desired output.

ps alx | grep apache

Output of this command will list you all those Apache processes but it will also show the grep command u enter to list down this result. Sometime we do not want this GREP command to be shown in our result may be for further processing. So we will run the same command as :

ps alx | grep apache |grep -v grep

Now it will not include the last result of grep. This helps running our next example of find command.

If you want to copy and move directories of a particular kind this command will be useful for you.
Say you want to search and copy all directories related to Apache :

find / | grep apache | cpio -pvdm ../

Make sure that the directory where you are copying the results exists on the location.

Leave a Comment

Free Domains Hosting at .co.nr Creative Commons License
This work by Ameya Pandit is licensed under a Creative Commons Attribution 2.5 India License
Photo Album