Hacker News new | ask | show | jobs
by ape4 1878 days ago
This makes me think there should be a Linux tool to extract the Nth line of a file. With options to get the N-Mth lines, etc
3 comments

There are many. Sed is fast. This will give you lines 11 to 500

sed -n '11,500p' < file.txt

Man pages can be tricky as the content can vary distro by distro (how up to date is your copy of man-pages, what changes have happened, etc.) - this technique is pretty portable to extract the synopsis of a man page specifically due to the format it uses (most times I'd use like grep -A3 -B2 foo /some/file, e.g.).
Ugly way to get the first indented line: `man systemd | grep '^ ' | head -1`

Which is the summary

Calling cut with a newline as the field delimiter works:

man systemd | cut -d $'\n' -f 4

Works with multiple lines too:

cut -d $'\n' -f 10-20,50-60