我发现在 bash 脚本中创建长管道非常强大,但我看到的主要缺点是似乎没有插入注释的方法。
举个例子,给这个脚本添加注释有什么好的方法吗?
#find all my VNC sessions
ls -t $HOME/.vnc/*.pid \
| xargs -n1 \
| sed 's|\.pid$||; s|^.*\.vnc/||g' \
| xargs -P50 --replace vncconfig -display {} -get desktop \
| grep "($USER)" \
| awk '{print $1}' \
| xargs -n1 xdpyinfo -display \
| egrep "^name|dimensions|depths"
最佳答案
让竖线成为每一行的最后一个字符并使用#
代替\
,像这样:
ls -t $HOME/.vnc/*.pid | #comment here
xargs -n1 | #another comment
...
关于bash:评论一个长管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5100788/