Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This makes no sense (too abstract of a statement), but here let's try this:

    $ man systemd | head -4 | tail -1
       systemd, init - systemd system and service manager
An email daemon (Postfix, Exim, Dovecot, UW-IMAP, Sendmail, etc.) are services running on a server. An "email server" would be a server running a daemon to provide email service in this example.


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


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


Makes plenty of sense: https://man7.org/linux/man-pages/man1/smtp.1.html

"SMTP transaction against an SMTP server"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: