LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 11-06-2003, 04:12 AM   #1
gummimann
Member
 
Registered: Nov 2003
Distribution: redhat
Posts: 57

Rep: Reputation: 15
Question Printing a line number


How can I in a shell script print a certain line?
For example: <command> --line-number=3 /myfile

Thnx
- Henki
 
Old 11-06-2003, 04:39 AM   #2
inTrouble?
LQ Newbie
 
Registered: Oct 2003
Posts: 5

Rep: Reputation: 0
head -3 myfile | tail -1

or

awk 'NR==3 {print $0}' myfile

prints the 3rd line of myfile
 
Old 11-06-2003, 06:09 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,524

Rep: Reputation: 93
sed -n 57p myfile.txt

prints line 57 of myfile.txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
extracting line number s_shenbaga Linux - Newbie 1 10-21-2005 05:52 AM
number of emails over command line kvtournh Linux - Software 1 01-11-2005 08:52 AM
looking for a way to dump line number info jbreazeale Linux - Software 2 09-22-2004 12:02 PM
Stray at line number vipinsharma Programming 1 05-21-2004 09:27 AM
Line number in Emacs as default saurya_s Linux - Software 1 01-28-2004 06:37 AM


All times are GMT -5. The time now is 02:47 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration