
ディレクトリ(サブディレクトリを含む)のすべての隠しファイルを削除するコマンドはありますか?
通常のファイルではなく隠しファイルのみを削除するには必要です。
答え1
find yourstartingpath/ -name ".*" -type f -exec rm {} \; -print
- 記載が必要な場合のみ印刷してください。
例:
francois@zaphod:~/tmp/test$ touch {a,b,c,a/1,a/2,b/2}/.hid
francois@zaphod:~/tmp/test$ touch {a,b,c,a/1,a/2,b/2}/nothid
francois@zaphod:~/tmp/test$ tree
.
├── a
│ ├── 1
│ │ └── nothid
│ ├── 2
│ │ └── nothid
│ └── nothid
├── b
│ ├── 2
│ │ └── nothid
│ └── nothid
└── c
└── nothid
6 directories, 6 files
francois@zaphod:~/tmp/test$ find . -name ".*" -type f -exec rm {} \; -print
./b/.hid
./b/2/.hid
./a/1/.hid
./a/.hid
./a/2/.hid
./c/.hid
francois@zaphod:~/tmp/test$ tree
.
├── a
│ ├── 1
│ │ └── nothid
│ ├── 2
│ │ └── nothid
│ └── nothid
├── b
│ ├── 2
│ │ └── nothid
│ └── nothid
└── c
└── nothid
6 directories, 6 files
francois@zaphod:~/tmp/test$
すべてのnothid(den)ファイルはそのまま残ります。
してください:最初にデータをバックアップせずにforループを開始したり、find ... exec rmコマンドを起動しないでください。 :)