[ACCEPTED]-How to output lines 800-900 of a file with a unix command?-head
Accepted answer
sed -n '800,900p' file.txt
This will print (p
) lines 800 through 900, including 6 both line 800 and 900 (i.e. 101 lines in 5 total). It will not print any other lines 4 (-n
).
Adjust from 800 to 801 and/or 900 to 3 899 to make it do exactly what you think 2 "between 800 and 900" should mean in your 1 case.
Found a prettier way: Using sed, to print 5 out only lines between a and b:
sed -n -e 800,900p filename.txt
From the 4 blog post: Using sed to extract lines in a text file
One way I am using it is to 3 find (and diff) similar sections of files:
sed -n -e 705,830p mnetframe.css > tmp1; \
sed -n -e 830,955p mnetframe.css > tmp2; \
diff --side-by-side tmp1 tmp2
Which 2 will give me a nice side-by-side comparison 1 of similar sections of a file :)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.