LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Read a line in a txt file with bash (http://www.linuxquestions.org/questions/linux-newbie-8/read-a-line-in-a-txt-file-with-bash-319620/)

orgazmo 05-03-2005 04:45 AM

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 ;-)

scuzzman 05-03-2005 05:10 AM

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.

orgazmo 05-03-2005 05:14 AM

ok i'll try it right now!!!

orgazmo 05-03-2005 05:16 AM

It works well!!! thanks a lot scuzzman ;-)


All times are GMT -5. The time now is 03:42 AM.