Re:Scripts I wrote that I use all the time
by southwindcg on Wednesday October 22, 2025 @01:54PM
(#45672747)
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:
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:
prints lines 2 through 4, inclusive.
[ Parent
| on HN ]
Re:Scripts I wrote that I use all the time
by tonmoy on Wednesday October 22, 2025 @02:32PM
(#45673268)
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
Re:Scripts I wrote that I use all the time
by 1-more on Wednesday October 22, 2025 @03:38PM
(#45674119)
yeah I almost always start with `cat` but I still pipe it into `sed -n 1,4p`
Re:Scripts I wrote that I use all the time
by southwindcg on Wednesday October 22, 2025 @02:36PM
(#45673321)
True, everything depends on what one is trying to do at the time.
Re:Scripts I wrote that I use all the time
by mmsc on Thursday October 23, 2025 @09:49AM
(#45681801)
If you'd like to print the middle of a file, try out `body`: https://github.com/megamansec/body