[email protected]# ./removedott.sh
Mon Nov 23 10:07:04 EST 2015 - Renaming tester.xml.P.T extension to xml
mv: `tester.xml.P.T' and `tester.xml' are the same file
removedott.sh:擊:重命名文件擴展名,收到錯誤
if [[ $(find . -type f -name "*.T" | wc -l) -gt 0 ]]
then
for f in *.T
do
echo "`date` - Renaming $f extension to xml"
y=${f%%.*}
mv -v -- "$f" "${y}.xml"
done
fi
我不知道爲什麼這個錯誤就要到了,我知道該文件是一樣的..這就是整個目的..我只想重命名它。
你在目錄中是否有'tester.xml'文件? (此外''find'測試可能更好地替換爲僅僅啓用'nullglob'和/或測試'* .T'作爲循環中'$ f'的值。) –
在目錄I中: touch tester .ABc.T 然後運行該腳本,在第一次傳遞時刪除.abc.T並將其重命名爲tester.xml。 如果我然後mv tester.xml到tester.abc.T並再次運行腳本,那當我得到錯誤 – sgwrist
如果它已經存在與你想要的名稱,你知道它,爲什麼你想要重命名它?我聞到[XY問題](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – tripleee