rm files - Linux

Table of Contents

請問

譬如資料夾底下有檔案1 2 3 4 5

我想保留檔案2的話可以使用 rm 1 3 4 5


但是當檔案很多的話
如有 1 2 3 ...999 1000

此時只想保留檔案2 5 10有沒有甚麼組合指令可以直接辦到??

除了cp 2 5 10到別的資料夾底下再全刪
然後在cp 2 5 10回來...


謝謝

--
per te io ruberò
ogni colore al cielo
dipingerò i miei piedi e ti raggiungerò
per lasciare una traccia un sentiero
che mi riporti da te

--

All Comments

Madame avatarMadame2009-07-13
regular expression
Elma avatarElma2009-07-13
shell scripts => if .... else rm ....
Heather avatarHeather2009-07-14
find \! \( -iname '2' -o -iname '5' -o -iname '10' \)
-delete
Carol avatarCarol2009-07-14
樓上的方法還蠻不錯的~:)