本文介绍了包含文件通配符猛砸变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个变量包含wildarded文件描述符:
I have a variable containing wildarded file descriptors:
FORMATS='*.mobi *.pdf *.txt *.epub *.lit'
它获取具有相应的文件扩展如果我写
It gets expanded with the appropriate files if I write
echo $FORMATS
如果我引用它保留其字符串值
and retains its string value if i quote it
echo "$FORMATS"
现在,我需要操纵它作为一个字符串,我这样做。
Now, I need to manipulate it as a string and I do this.
SUBST=`echo "$FORMATS" | sed "s/$1//"`
问题是,在``的文件遭到反正扩大。如何prevent呢?谢谢你。
The problem is that within `` the files get expanded anyway. How to prevent this? Thanks.
推荐答案
没有,它不会得到扩展!
No, it doesn't get expanded!
什么你可能做的是用 SUBST
不带引号(如:回声$ SUBST
),然后它会扩大...使用$ SUBST
。
What you are probably doing is using SUBST
without quotes (eg: echo $SUBST
) and then it gets expanded... use "$SUBST"
.
这篇关于包含文件通配符猛砸变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!