我正在尝试做一个 bash 脚本,它只为我提供“n”命令的第一行 man。
例子:
$ sh ./start.sh ls wazup top
ls - list directory contents
wazup - manpage does not exist
top - display Linux tasks
这是我当前的代码:
! 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
我的输出是:
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