Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-19-2009, 03:57 PM
|
#1
|
LQ Newbie
Registered: May 2004
Location: Ottawa, Ontario, Canada
Distribution: Redhat 9
Posts: 20
Rep:
|
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
|
|
|
02-19-2009, 04:15 PM
|
#2
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
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.
|
|
|
02-19-2009, 04:26 PM
|
#3
|
Senior Member
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
|
will give every line after (including) line 200 in file
|
|
|
02-19-2009, 04:44 PM
|
#4
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
|
|
|
02-20-2009, 01:29 PM
|
#5
|
LQ Newbie
Registered: May 2004
Location: Ottawa, Ontario, Canada
Distribution: Redhat 9
Posts: 20
Original Poster
Rep:
|
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 02:28 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|