LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash : read every line from text file starting at given line number (https://www.linuxquestions.org/questions/programming-9/bash-read-every-line-from-text-file-starting-at-given-line-number-706003/)

quadmore 02-19-2009 02:57 PM

bash : read every line from text file starting at given line number
 
Hello,

I have a complicated parsing script.

Say my parameter is line number 200. I know my file has more lines than the given parameter.

head -c 200 filename
would give me the first 200 which is not what I need.

What I need is every line starting at line number 200.

I was hoping not to have to nest yet another loop.

TIA for all suggestions,

Bert

David the H. 02-19-2009 03:15 PM

sed -n '200,$p' textfile should work.

Note that the $ needs to be escaped or enclosed in single-quotes, or else your shell will interpret $p as if it were a variable.

bgeddy 02-19-2009 03:26 PM

Code:

tail -n+200 file
will give every line after (including) line 200 in file

colucix 02-19-2009 03:44 PM

Code:

awk 'NR>=200' file

quadmore 02-20-2009 12:29 PM

Thank you very much
 
All three solutions work perfectly on my system, I tip my hat to you.

Thank you very much.

Cheers,
Bert


All times are GMT -5. The time now is 07:29 PM.