I need to find files of the form ' abc.111 ' in a directory and rename them as ' abc.222 ' in my shell script. The pattern substitution fails somehow. What am I missing here?
#!/bin/sh
find . -name \*abc\* | while read FILES
do
newfile = ${FILES/111/222} #Replace 111 by 222
mv $FILES $newfile
done
Error : /temp.sh: bad substitution
Your /bin/sh
does not support ${var//}
substitution. Try another shell, such as /bin/bash
.
Once you fix that, you will find that spaces do not work.
newfile = ${FILES/111/222}
You must write this line without spaces on either side of =
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.