Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Linux
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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

Reply With Quote
  #2 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:32 PM.


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