buk*_*zor 5 bash comments pipeline sh
我发现在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"
Run Code Online (Sandbox Code Playgroud)
Eel*_*vex 21
让管道成为每一行的最后一个字符,#而不是使用\,如下所示:
ls -t $HOME/.vnc/*.pid | #comment here
xargs -n1 | #another comment
...
Run Code Online (Sandbox Code Playgroud)
这也适用:
# comment here
ls -t $HOME/.vnc/*.pid |
#comment here
xargs -n1 |
#another comment
...
Run Code Online (Sandbox Code Playgroud)
基于/sf/answers/357057501/。它归结为s/|//;s!\!|!。
| 归档时间: |
|
| 查看次数: |
1025 次 |
| 最近记录: |