
ファイル名が大文字か小文字かを無視してファイルまたはディレクトリを削除する方法はありますか?
例: 私は/FiLe
と の両方です/file
。
次のように書くと、rm /file
これら 2 つは削除されますか?
答え1
悪い解決策:
rm [Ff][Ii][Ll][Ee]
より良い:
find . -iname "file" -exec rm {} \;
から男:
-iname pattern
Like -name, but the match is case insensitive.
また、深さを現在のディレクトリのみに制限するには、-maxdepth 1
次の前に追加しますiname
。
find . -maxdepth 1 -iname "file" -exec rm {} \;
お役に立てれば幸いです。