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
how to display line number for tail -f iengca UNIX for Dummies Questions & Answers 4 12-13-2007 08:46 AM
Want display a line with space in file by unix script arunkumar_mca UNIX for Dummies Questions & Answers 9 05-21-2007 01:12 PM
unable to display the souce line in gdb gauri UNIX for Dummies Questions & Answers 4 04-19-2007 09:36 PM
Need to display sorted output on 1 line! knc9233 UNIX for Dummies Questions & Answers 2 01-17-2007 10:26 PM
Display Printers via command line gseyforth Windows & DOS: Issues & Discussions 3 06-28-2006 02:02 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 07-31-2006
Rohini Vijay Rohini Vijay is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 16
Display a particular line from a file

Hi,

What is the command i can use iof i want to display a particular line from a file, i have the line number with me.
  #2 (permalink)  
Old 07-31-2006
suman_jakkula suman_jakkula is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 35
head -n filename | tail -1
n = linenumber
  #3 (permalink)  
Old 07-31-2006
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393

Code:
sed -n "${line_number}p"  $filename

  #4 (permalink)  
Old 07-31-2006
Rohini Vijay Rohini Vijay is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 16
Hi Friends,

Thank you so much, now i have 2 options to achieve the functionality.
  #5 (permalink)  
Old 07-31-2006
Rohini Vijay Rohini Vijay is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 16
Hi Klashxx,

The command is serving the purpose but can you please let me know the meaning of the options supplied :

sed -n "linenumber p" filename

i know p option is to print ... but how does -n work.

This is only for my knowledge.

Thanks again !
  #6 (permalink)  
Old 07-31-2006
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
The -n flag suppress automatic output of input lines.

Cheers.
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 02:02 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