对于文件
test_001.log
test_002.log
我想将它们重命名为
001_test.log
002_test.log
我认为它应该是这样的
for f in *.log; do mv "$f" "`echo $f | sed s/test_\(.*\)\.log/\1_test.log/`"; done
但我得到了错误
mv: `test_001.log' and `test_001.log' are the same file
我在这里做错了什么?
这是工作片段:
for f in *.log; do mv $f `echo $f | sed 's/test_\(.*\)\.log/\1_test.log/'`; done;
我认为您错过了引用's/test_\(.*\)\.log/\1_test.log/'
,这可能不会返回您的期望。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句