我有,
我的
while IFS= read -r line ; do
v1="$line";
t1=`echo $line | awk -F= '{print $2}'`
echo "$t1"
done < $1
sample.txt
say=hello
test=0 0/15 * * * ?
logs=valuelogs
输出 :
[root@centos gen]# ./my.sh test.txt
hello
0 0/15 hello.txt 2.txt tmp.log my.sh sample.txt test.sh test.txt hello.txt
2.txt tmp.log my.sh sample.txt test.sh test.txt hello.txt 2.txt tmp.log
my.sh sample.txt test.sh test.txt ?
valuelogs
在这里,由于执行了类似的命令echo *
,并且输出当前目录中的文件列表,我们得到了不好的输出。
是否有其他替代解决方案?
问题出echo $line
在反引号里面。用双引号括起来以防止通配符扩展:
t1=`echo "$line" | awk -F= '{print $2}'`
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句