Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个从标准输入读取行的 bash 脚本。
while read var do echo $var done
现在,我必须修改它,以便我可以接受带有行分隔符“EndOfMessage”(几个符号的分隔符)的输入。
我怎么能那样做?
如果我理解正确,输入将类似于“line1EndOfMessageline2EndOfMessageline3”?如果是这样,您可以这样做:
sed $'s/EndOfMessage/\\\n/g' | while read var; do echo $var done