readpipe.sh

来自「Shall高级编程」· Shell 代码 · 共 36 行

SH
36
字号
#!/bin/sh# readpipe.sh# This example contributed by Bjon Eriksson.last="(null)"cat $0 |while read linedo    echo "{$line}"    last=$linedoneprintf "\nAll done, last:$last\n"exit 0  # End of code.        # (Partial) output of script follows.        # The 'echo' supplies extra brackets.#############################################./readpipe.sh {#!/bin/sh}{last="(null)"}{cat $0 |}{while read line}{do}{echo "{$line}"}{last=$line}{done}{printf "nAll done, last:$lastn"}All done, last:(null)The variable (last) is set within the subshell but unset outside.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?