Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在目录中找到格式为“ abc.111 ”的文件,并在我的 shell 脚本中将它们重命名为“ abc.222 ”。模式替换以某种方式失败。我在这里想念什么?
#!/bin/sh find . -name \*abc\* | while read FILES do newfile = ${FILES/111/222} #Replace 111 by 222 mv $FILES $newfile done
错误:/temp.sh:替换错误
您的/bin/sh不支持${var//}替换。尝试另一个 shell,例如/bin/bash.
/bin/sh
${var//}
/bin/bash
一旦你解决了这个问题,你会发现空格不起作用。
newfile = ${FILES/111/222}
您必须在=.
=