1
我需要shell脚本语句来替换"*"
符号和字符串中的".*"
。例如:string1="abc*def"
转换为此string2:"abc.*def"
。我与这段代码尝试,但它给出错误的输出:替换字符串中的字符
IN="abc*def"
chr=".*"
arr=$(echo ${args[@]} | tr "*" "\n")
for x in $arr
do
echo -n $x
echo -n ".*"
done
for abc*def gives abc.*def.* not correct
for abc*def* gives abc.*def.* correct
for *abc*def* gives abc.*def.* not correct
谢谢!它解决了我的问题 – BattleArray61 2014-11-05 06:14:35
不客气,很高兴它解决了。 – anubhava 2014-11-05 06:14:59