我如何逃脱在bash通配符/星号字符? [英] How do I escape the wildcard/asterisk character in bash?

查看:108
本文介绍了我如何逃脱在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?

How do I get the output "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通配符/星号字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆