如何把所有 有whitespace的檔名 改成沒有的? - Linux

By Dora
at 2008-09-30T03:25
at 2008-09-30T03:25
Table of Contents
大家好,
我的目錄底下有很多如下的檔名:
\ \ 1
\ \ 2
\ 10
\ 20
等等.
我想把他改成
1
2
10
20
請問有沒有什麼簡單的方法?
我目前的作法是
for FILE in $(find . -type f); do mv "$FILE $(echo $FILE | tr -d '\ ')"; done
但出現的結果是:
mv ./ ./
mv 1 1
而不是我想要的
mv ./\ \ 1 ./1
我猜測是因為$(find . -type f)裡裝的是
./ 1 ./ 10 ./ 2 ./ 20
(這是echo $(find . -type f)的結果)
也就是說檔名的空白變成分隔字元了?
我應該怎麼辦?
--
我的目錄底下有很多如下的檔名:
\ \ 1
\ \ 2
\ 10
\ 20
等等.
我想把他改成
1
2
10
20
請問有沒有什麼簡單的方法?
我目前的作法是
for FILE in $(find . -type f); do mv "$FILE $(echo $FILE | tr -d '\ ')"; done
但出現的結果是:
mv ./ ./
mv 1 1
而不是我想要的
mv ./\ \ 1 ./1
我猜測是因為$(find . -type f)裡裝的是
./ 1 ./ 10 ./ 2 ./ 20
(這是echo $(find . -type f)的結果)
也就是說檔名的空白變成分隔字元了?
我應該怎麼辦?
--
Tags:
Linux
All Comments

By Robert
at 2008-10-01T04:21
at 2008-10-01T04:21

By Tracy
at 2008-10-03T19:43
at 2008-10-03T19:43

By Hedwig
at 2008-10-07T12:51
at 2008-10-07T12:51

By Mason
at 2008-10-08T04:30
at 2008-10-08T04:30
Related Posts
CentOs 5.2 安裝問題Part2

By Margaret
at 2008-09-29T22:24
at 2008-09-29T22:24
考NCLP證照

By Ula
at 2008-09-29T19:42
at 2008-09-29T19:42
CentOs5.2 怎麼灌?

By Audriana
at 2008-09-29T14:07
at 2008-09-29T14:07
網頁中的資料夾刪不掉

By Ida
at 2008-09-29T13:59
at 2008-09-29T13:59
請問如何還原GHO檔裡的一個資料夾?

By Robert
at 2008-09-29T13:54
at 2008-09-29T13:54