Is it possible to output 38 lines in between x & y on a text file?
I'm using Debian, remote only access.
I have a long text file that I want to read/output to my console, but only the 38 lines that are between x and y. The 'location' of these lines within the file might change but the lines themselves do not change. Is there a command to output to my console only the 38 lines that is 'in between' these two lines: %d blah blah blah%a (38 lines of text here) blah blah: %d Thank you so much :) |
Hi juliej,
If i got you correct, Quote:
|
/me jumps up and hugs RaviTezu
thank you :) That is perfect! I was over thinking it with the 'in between' hehe. btw did I say THANK YOU :D |
Some other options:
Using gnu sed: Code:
sed -n ' /pattern/,+38p' infile.txt Code:
ed -s infile.txt <<<'/pattern/;+38p' If you want to get the part between the two patterns, whatever the number of lines, and with or without the bracketing lines: Code:
#includes bracketing lines: Here are a few useful sed references: http://www.grymoire.com/Unix/Sed.html http://sed.sourceforge.net/grabbag/ http://sed.sourceforge.net/sedfaq.html http://sed.sourceforge.net/sed1line.txt http://www.catonmat.net/series/sed-one-liners-explained How to use ed: http://wiki.bash-hackers.org/howto/edit-ed http://snap.nlc.dcccd.edu/learn/nlc/ed.html (also read the info page) |
All times are GMT -5. The time now is 09:42 AM. |