I have a big file with 1000 lines.I wanted to get 110 lines from it. Lines should be evenly spread in Input file.
For example,I have read 4 lines from file with 10 lines
Input File
1 2 3 4 5 6 7 8 9 10
outFile:
1 4 7 10
Use:
sed -n '1~9p' < file
The -n option will stop sed from outputting anything. '1~9p' tells sed to print from line 1 every 9 lines (the p at the end orders sed to print).
To get closer to 110 lines you have to print every 9th line (1000/110 ~ 9).
Update: This answer will print 112 lines, if you need exactly 110 lines, you can limit the output just using head like this:
sed -n '1~9p' < file | head -n 110
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With