The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using grep to extract line number mskarica Shell Programming and Scripting 8 06-26-2008 02:47 AM
Grep a number from a line in ksh rodluo Shell Programming and Scripting 3 12-09-2007 09:31 AM
Get Filename and Line Number using grep ceemh3 UNIX for Dummies Questions & Answers 4 09-17-2007 10:35 AM
is there any why to get the number of line in grep result ? umen UNIX for Dummies Questions & Answers 1 03-16-2006 09:56 AM
substitute string according line number nir_s Shell Programming and Scripting 4 07-19-2005 07:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 12-01-2007
salaathi's Avatar
salaathi salaathi is offline
Registered User
  
 

Join Date: Sep 2007
Location: Madurai
Posts: 20
Question grep the string with the line number

Dear Masters,
Here i have some doubts can anyone clarify?.

Is it possible to grep the lines by specifying the line numbers.

I know the line number which i want to grep.
example:
grep 40th line filename
grep 50th line filename


Need ur comments.

Last edited by salaathi; 12-01-2007 at 06:54 AM.. Reason: to simplify the readers understand
  #2 (permalink)  
Old 12-01-2007
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
To print the 40th line:

Code:
sed '40q;d' file
or
Code:
awk 'NR==40 {print;exit}'
Regards
  #3 (permalink)  
Old 12-01-2007
nirav_soni nirav_soni is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 12
You can use nawk 'NR==40' filename to grab particular line
  #4 (permalink)  
Old 12-01-2007
salaathi's Avatar
salaathi salaathi is offline
Registered User
  
 

Join Date: Sep 2007
Location: Madurai
Posts: 20
Thumbs up

Dear all,
Thanks a lot.
  #5 (permalink)  
Old 12-04-2007
JeepResQ's Avatar
JeepResQ JeepResQ is offline
Registered User
  
 

Join Date: Nov 2007
Location: maryland...until i move back to va
Posts: 10
Thumbs up hey

you gotta love help you get in here...these folks are freekin awesome!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 06:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0