Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Linux
| Search | Today's Posts | Mark Forums Read
Linux General discussion of programming the various flavors of Linux operating systems.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Linux section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2006, 07:56 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default grep, sort with pipe

I am learning to use grep, sort with pipe

What I want to do is use grep to find all files in Linux containing the the string "etc". And pipe the result into sort.

Grep –r etc * | sort > etc-grep.txt

Running it from the / directory. This command hangs - what am I doing wrong ?

Thanks

Brendon

 
Old October 25th, 2006, 11:46 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

the / directory is the root of your file system, so before it will return it'll have to recursively open and grep every single file on your hard drive for the string 'etc'. Then it will have to sort all the lines which it finds. This will unfortunately take a while!

Try the same command in your home directory:

Code:
$ cd ~
$ grep -r some_string * | sort
HTH

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com




Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
grep-search for text within files, within folders crmpicco Linux 2 September 1st, 2007 10:23 AM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
grep e$ words2.txt doesn't work plantseeker BOOK Beginning Linux Programming, 3rd Edition 1 December 12th, 2005 02:46 PM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.