LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sed print range to end of file (https://www.linuxquestions.org/questions/programming-9/sed-print-range-to-end-of-file-717714/)

schneidz 04-08-2009 09:36 AM

sed print range to end of file
 
hi, i would like to know how to print (in this case) from line # 298,147 to the last line of the file:
Code:

sed -n 298147,$p hosp-file
sed: 0602-404 Function 298147, cannot be parsed.

thanks,

colucix 04-08-2009 09:42 AM

Code:

sed -n '298147,$ p' hosp-file
The single quotes are necessary in this case to protect the $ sign from the shell substitution. Otherwise, you can always use tail:
Code:

tail -n +298147 hosp-file

pixellany 04-08-2009 09:51 AM

Quote:

Originally Posted by colucix (Post 3502501)
Code:

sed -n '298147,$ p' hosp-file
Maybe the single quotes are necessary in this case to protect the $ sign from the shell substitution.[/CODE]

Delete "maybe".....;)
The sed books say always start with single quotes, and then back off to double-quotes where necessary.

colucix 04-08-2009 09:59 AM

Quote:

Originally Posted by pixellany (Post 3502513)
Delete "maybe".....;)
The sed books say always start with single quotes, and then back off to double-quotes where necessary.

Maybe deleted... as per your suggestion! ;) Thanks, pixellany!

pixellany 04-08-2009 01:30 PM

At the next Nitpickers Convention, I'll buy you a beer......;)


All times are GMT -5. The time now is 06:23 PM.