The UNIX and Linux Forums  

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
awk print the next line on the current line ajp7701 Shell Programming and Scripting 5 05-25-2009 01:17 PM
use variable for sed print line atchleykl UNIX for Dummies Questions & Answers 3 02-23-2009 01:49 PM
print line whatever line i want in a file... there any way kittusri9 Shell Programming and Scripting 1 05-15-2008 01:37 PM
Read line by line from a variable. sathishkmrv Shell Programming and Scripting 9 09-13-2007 11:25 AM
Print file line by line handak9 Shell Programming and Scripting 2 10-20-2005 09:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-07-2008
RahulJoshi's Avatar
RahulJoshi RahulJoshi is offline
Registered User
  
 

Join Date: Aug 2008
Location: PUNE
Posts: 98
print any required line by its line no using awk and its NR variable

how to print any required line by its line no using awk and its NR variable
for eg:
------------
121343
adfdafd
21213sds
dafadfe432
adf.adf%adf
---------------
requied o/p if give num=3 it print:
21213sds
--------------------------------------
  #2 (permalink)  
Old 09-07-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 611
Try:


Code:
var=<specify line number>
awk -v val=$var ' NR==val { print; }' filename


Last edited by dennis.jacob; 09-07-2008 at 03:37 AM.. Reason: modified the code
  #3 (permalink)  
Old 09-07-2008
RahulJoshi's Avatar
RahulJoshi RahulJoshi is offline
Registered User
  
 

Join Date: Aug 2008
Location: PUNE
Posts: 98
thanks dennis its works.
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 10:51 AM.


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