The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using find command for timestamp based search sunny_03 UNIX for Dummies Questions & Answers 1 02-12-2008 02:38 AM
String search - Command to find second occurance saurabhsinha23 UNIX for Dummies Questions & Answers 5 12-06-2007 05:03 PM
grep with find to search for matchiing words akhil313 UNIX for Dummies Questions & Answers 1 12-12-2006 07:18 AM
search in a directory using grep command malaymaru Shell Programming and Scripting 4 05-23-2005 06:45 AM
search for hardlinks based on filename via find command hunternjb UNIX for Dummies Questions & Answers 2 03-26-2001 09:07 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-22-2007
Registered User
 

Join Date: Aug 2004
Posts: 141
Search / Find / grep command ...

Is there any command, so I can retrieve all the records in a file from the first occurance of a search string, within that file?
Reply With Quote
Forum Sponsor
  #2  
Old 02-22-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
I would say,

'NO' to retrieve all the patterns just from the first occurrence of the search string from a file

Code:
grep ^pattern file
How would the grep evaluate othe patterns by just identifying the first occurrence of the search string?

If I havent understood your req, then I need to rethink
Reply With Quote
  #3  
Old 02-22-2007
Registered User
 

Join Date: Aug 2004
Posts: 141
Ok, let me be clear in my question.

A,1
B,2
C,3
D,4
E,5


If I search for C, then I should get output as below,

C,3
D,4
E,5

grep ^C file, is returning me only 1 row. It is not helping me.
Reply With Quote
  #4  
Old 02-22-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
this is clear

Code:
awk '/^C/, /\$/ {print }' file
Reply With Quote
  #5  
Old 02-22-2007
Registered User
 

Join Date: Aug 2004
Posts: 141
Thanks, it works as expected.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0