LinuxQuestions.org
Help answer threads with 0 replies.
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 05-03-2005, 03:45 AM   #1
orgazmo
Member
 
Registered: May 2005
Location: Paris, france
Posts: 53

Rep: Reputation: 15
Read a line in a txt file with bash


Hi all!

First excuse me for my bad english, but i'm french.

Well... let's stick to the question. In fact I'm looking for a unix command that would allow me to display a precise line of a text file in the console in order to do a grep on an other file to check if the line is in the second file too.

I first planed to use diff to compare my files, but it does'nt match my needs.

Something like that would be perfect:

Command -line_number file.txt.

Thank you ;-)
 
Old 05-03-2005, 04:10 AM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Try this:
Code:
sed -n '#p' filename
Replace the # with a number. Hence, to return line 52, you'd use:
Code:
sed -n '52p' filename
See this: Handy one-liners for sed.

Last edited by scuzzman; 05-03-2005 at 04:11 AM.
 
Old 05-03-2005, 04:14 AM   #3
orgazmo
Member
 
Registered: May 2005
Location: Paris, france
Posts: 53

Original Poster
Rep: Reputation: 15
ok i'll try it right now!!!
 
Old 05-03-2005, 04:16 AM   #4
orgazmo
Member
 
Registered: May 2005
Location: Paris, france
Posts: 53

Original Poster
Rep: Reputation: 15
It works well!!! thanks a lot scuzzman ;-)
 
  


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 57 04-17-2016 06:07 PM
BASH: Read entire file line in for loop clinton Programming 16 04-18-2013 12:06 PM
bash: read a line from file zokik Linux - General 6 12-10-2008 09:24 AM
Read a line in a txt file with bash orgazmo Programming 5 05-03-2005 07:10 AM
linux scripting help needed read from file line by line exc commands each line read atokad Programming 4 12-26-2003 10:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:41 AM.

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
Open Source Consulting | Domain Registration