2015年12月14日 星期一

Rename 重新命名

I have the below list of files
aro_tty-mIF-45875564pmo_opt
aro_tty-mIF-45875664pmo_opt
aro_tty-mIF-45875964pmo_opt
aro_tty-mIF-45875514pmo_opt
aro_tty-mIF-45875524pmo_opt
that I need to rename to
aro_tty-mImpFRA-45875564pmo_opt
aro_tty-mImpFRA-45875664pmo_opt
aro_tty-mImpFRA-45875964pmo_opt
aro_tty-mImpFRA-45875514pmo_opt
aro_tty-mImpFRA-45875524pmo_opt
Answer:
for file in aro_tty-mIF-*_opt
do
    mv -i "${file}" "${file/-mIF-/-mImpFRA-}"
done

echo $a
abc.ooo.xxx

#檔名
echo ${a%.*}
abc.ooo

#副檔名
echo ${a##*.}
xxx


ref : Here

沒有留言:

張貼留言