LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2003, 07:44 PM   #1
charlie123
Member
 
Registered: Jan 2003
Location: S.E. England
Distribution: Redhat 8.0
Posts: 64

Rep: Reputation: 15
Printing a specific line


Hey, i have search but i must be looking for the wrong thing cos i cant find any answers.
Basically, in the terminal, how can i print a specified line from a file (like line 4). i have read through grep, more, less and cat manuals but none of them seem to have the option to print only one specified line.

does anyone know of a command that will do this?

Many thanks

CHarlie
 
Old 02-10-2003, 11:11 AM   #2
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
Sed does:

# sed -n 1p file

this will print the first line of a file...
 
Old 02-10-2003, 11:59 AM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Well... I imagine there is a better way than this, but you could use a combination of head and tail. Say you wanted line 15 from a file named my_text.txt:
Code:
head -15 my_text.txt | tail -1
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill specific Wine program from Command Line Brian114 Linux - Software 4 06-07-2011 05:02 AM
Extracting a specific line from an ASCII file heyyou Programming 7 03-21-2005 05:19 PM
Command line tools to Find files with specific text naps Linux - Software 5 11-15-2004 05:46 AM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 02:39 PM
starting X from the command line in a specific resolution jdaniel Linux - General 5 09-10-2003 10:25 PM


All times are GMT -5. The time now is 04:27 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration