我有这样的字符串
/home/rm/home-scripts/originals/audicerttest/incoming/TEST040511.txt
/home/rm/home-scripts/originals/audicerttest2/incoming/TEST040512.txt
/home/rm/home-scripts/originals/audicerttest3/incoming/TEST040513.txt
等等..我想将字符串'audicerttest/incoming'、audicerttest2/incoming'等提取到一个shell变量中,然后在脚本中使用它。我尝试过这样的事情。
for file in `find ${ROOT}/* -type f | grep -v -f test.txt`
do
let count++
echo ${count}: ${file}
echo ${file} | eval $(awk '{split($0,a,"/"); print "abc=a[6]/a[7]"}' < /dev/null)
echo abc====$abc
done
但它没有为 abc 提供任何输出。