send man page to text file
Printing a manpage to a text file (perhaps more portable for cross-platform or bedtime reading):
generic Unix/Linux, using `col`:
man rcs | col -b > /tmp/man_rcs.txt
These alternatives would require that you reset PAGER or MANPAGER:
alternative BSD :
export MANPAGER=cat
man pf.conf > man_pf.conf.txt
alternative BSD :
export PAGER=cat
man pf.conf > man_pf.conf.txt
Ubuntu, Debian, Mint, etc. allow all of these alternatives:
-P pager, --pager=pager
Specify which output pager to use. By default, man uses pager -s. This option overrides the $MANPAGER environment variable, which in turn overrides the $PAGER environment variable. It is not used in conjunction with -f or -k.
linux/Unix tools for multiline grep
grep -A 2 SearchString
grep -B 3 SearchString
also,
pcregrep
pcregrep -M ‘a\nb’ files…
redirecting standard error (stderr) and standard output (stdout) to a file
Capturing both errors and normal list output from ls, with “long” and recursive options set, to a file called /tmp/allout :
ls -lR > /tmp/allout 2>&1