I have an example [file] that I want to Grab lines 3-6 and lines 11 – 13 then sort with a one line command and save it as 3_6-11_13. These are the commands I have used thus far but I haven’t gotten the desired output:
sed -n '/3/,/6/p'/11/,/13/p file_1 > file_2 | sort -k 2 > file_2 & sed -n 3,6,11,13p file_1 > file_2 | sort -k 2 file_2.
Is there a better way to shorten this. I have thought about using awk but have I stayed with sed so far.
With
sedyou’re allowed to specify addresses by number like so:The
-nis to keepsedfrom automatically printing output.Then you can run multiple commands if you’re using
gsedby separating those commands with semicolons: