sh read 命令会吃掉输入中的反斜杠吗?
也许最容易用一个例子来解释:
$ echo '\&|'
\&|
$ echo '\&|' | while read in; do echo "$in"; done
&|
读取命令似乎将输入中的反斜杠解释为转义符并删除它们。 我需要逐行处理文件而不更改其内容,并且我不知道如何停止在这里智能读取。 有任何想法吗?
Perhaps easiest to explain with an example:
$ echo '\&|'
\&|
$ echo '\&|' | while read in; do echo "$in"; done
&|
It seems that the read
command is interpreting the backslashes in the input as escapes and is removing them. I need to process a file line by line without changing its contents and I'm not sure how to stop read from being smart here. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据:http://www.vias.org/linux-knowhow/bbg_sect_08_02_01.html< /a>:
它可以在我的机器上运行。
Accrding to: http://www.vias.org/linux-knowhow/bbg_sect_08_02_01.html :
It works on my machine.
使用
read -r
,按照 http://www.ss64.com /bash/read.html:Use
read -r
, as per http://www.ss64.com/bash/read.html: