bash参数替换$ {REV %% \ n *}中的新行 [英] new line in bash parameter substitution ${REV%%\n*}
本文介绍了bash参数替换$ {REV %% \ n *}中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不起作用
echo $ {REV %% \ n *}
起作用
echo $ {REV %%*}
阅读低谷后 http://tldp.org/LDP/abs/html/parameter-substitution.html 我仍然不知道如何使\ n工作.
解决方案
$ {REV %% $'\ n *'}
似乎有效.参见 bash文档的引用部分.>
does not work
echo ${REV%%\n*}
does work
echo ${REV%%
*}
After reading trough http://tldp.org/LDP/abs/html/parameter-substitution.html I still can not figure out how to make \n work.
解决方案
${REV%%$'\n*'}
seems to work. See the quoting section of the bash documentation.
这篇关于bash参数替换$ {REV %% \ n *}中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文