I'm trying to do a bash script which gives me only the first line of man for "n" commands.
example:
$ sh ./start.sh ls wazup top
ls - list directory contents
wazup - manpage does not exist
top - display Linux tasks
This is my current code:
! bin/bash/
while [ -n "$1" ]
do
which $1> /dev/null
man $1 | head -6 | tail -1
if [ $? = 0 ]
then
echo "manpage does not exist"
fi
shift
done
My Output is:
ls - list directory contents
manpage does not exist
No manual entry for wazzup
manpage does not exist
top - display Linux processes
manpage does not exist
Check the status code returned by man, not once it's piped through head and tail (which will be wrong as it will be the return status of tail).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With