本文介绍了如何在 bash 中转义通配符/星号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
me$ FOO="BAR * BAR"
me$ echo $FOO
BAR file1 file2 file3 file4 BAR
并使用 转义字符:
me$ FOO="BAR * BAR"
me$ echo $FOO
BAR * BAR
我显然在做一些愚蠢的事情.
I'm obviously doing something stupid.
如何获得输出BAR * BAR
?
推荐答案
设置 $FOO
时引用是不够的.您还需要引用变量引用:
Quoting when setting $FOO
is not enough. You need to quote the variable reference as well:
me$ FOO="BAR * BAR"
me$ echo "$FOO"
BAR * BAR
这篇关于如何在 bash 中转义通配符/星号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!