【发布时间】:2018-05-12 04:19:58
【问题描述】:
我有一个命令
lsof -i :3000
当我运行它时,我得到了这个
⚡️lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 6803 bheng 13u IPv6 0xa757c4ba1a0bf589 0t0 TCP *:hbci (LISTEN)
我想为这个命令创建一个别名,它将一个参数作为我的端口号。
我不打算为此创建一个函数或任何东西。
我试过了
alias checkport='lsof -i :$1'
我想这样使用它
checkport 3000
结果
⚡️checkport 3000
lsof: unacceptable port specification in: -i :
lsof 4.89
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhlnNoOPRtUvV] [+|-c c] [+|-d s] [+D D] [+|-f[cgG]]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
【问题讨论】: