LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-16-2006, 01:35 PM   #1
SkipHuffman
Member
 
Registered: Mar 2005
Posts: 81

Rep: Reputation: 15
How to read a single line from a text file into a shell script.


How can I pull a specified line from a plain text file in a shell script?

Basically I need to pull line X from file Y.

Assistance please.
 
Old 08-16-2006, 01:57 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Using sed is a possibility:

LINE_FIVE="`sed -n '5p' infile`"

Hope this helps.
 
Old 08-16-2006, 02:10 PM   #3
SkipHuffman
Member
 
Registered: Mar 2005
Posts: 81

Original Poster
Rep: Reputation: 15
Yup, that is what I need.

Thanks!
 
  


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
bash shell script read file line by line. Darren[UoW] Programming 51 07-04-2013 08:16 PM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM
How to delete a line from a text file with shell script programming Bassam General 1 01-28-2004 08:51 PM
reading a single line of a text file davi_cabral Linux - Software 1 10-29-2003 12:24 PM
Display/Read line 'N' in a text file using script ganninu Linux - Newbie 2 10-13-2003 05:28 AM


All times are GMT -5. The time now is 12:10 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 Google+: linuxquestions
Open Source Consulting | Domain Registration