←back to thread

768 points speckx | 1 comments | | HN request time: 0s | source
Show context
southwindcg ◴[] No.45672747[source]
Regarding the `line` script, just a note that sed can print an arbitrary line from a file, no need to invoke a pipeline of cat, head, and tail:

    sed -n 2p file
prints the second line of file. The advantage sed has over this line script is it can also print more than one line, should you need to:

    sed -n 2,4p file
prints lines 2 through 4, inclusive.
replies(1): >>45673268 #
tonmoy ◴[] No.45673268[source]
It is often useful to chain multiple sed commands and sometimes shuffle them around. In those cases I would need to keep changing the fist sed. Sometimes I need to grep before I sed. Using cat, tail and head makes things more modular in the long run I feel. It’s the ethos of each command doing one small thing
replies(2): >>45673321 #>>45674119 #
1. southwindcg ◴[] No.45673321[source]
True, everything depends on what one is trying to do at the time.