Assume I have a file with about 10000 lines.
How can I print 100 lines, starting from line 1200 to line 1300?
Assume I have a file with about 10000 lines.
How can I print 100 lines, starting from line 1200 to line 1300?
With awk this would be awk 'NR >= 1200 && NR <= 1300'
with sed: sed -n '1200,1300 p' FILE
with head and tail: head -n 1300 FILE | tail -n 100
so many options, so many answers on stackexchange :)
LINE=$(head -3 things.txt |tail -1) ex numbers.txt <<eof 6 insert "$LINE" . xit eof
#--------
Append rather than insert to say, line 6 do the following with sed:
LINE=$(head -3 things.txt |tail -1) sed '6s/$/ "$LINE"/' numbers.txt
This use of sed will only echo the change without writing it, if you want to save the changes you can echo the output to a new file
sed '6s/$/ "$LINE"/' numbers.txt >numbers2.txt
– unifex Jun 17 '23 at 19:33