LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   SED - display text on specific line of text file (http://www.linuxquestions.org/questions/linux-software-2/sed-display-text-on-specific-line-of-text-file-397405/)

3saul 12-28-2005 09:08 PM

SED - display text on specific line of text file
 
Does anybody know how I can do this?

Snowbat 12-28-2005 09:12 PM

From http://www.student.northpark.edu/pem...d/sed1line.txt
Quote:

# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files

3saul 12-28-2005 09:37 PM

One more question
 
That works wonderfully thankyou. However do you know how I can allow the shell to recognize the variable in this:

sed '$Variableq;d' files

Thanks

Snowbat 12-29-2005 04:32 PM

Bash script:
Code:

#!/bin/bash
VARIABLE=2
cat example.txt | sed $VARIABLE'q;d'

Command line:
Code:

VARIABLE=2; cat example.txt | sed $VARIABLE'q;d'


All times are GMT -5. The time now is 08:22 PM.