最後更新: 2021-02-24
前言
如果檔案名包含一些"特別"符號時, 要對它們操作會比較困難
特別的符號(Meta-characters) 有
- semicolons (;)
- spaces ( )
- backslashes (\)
- dollar signs ($)
- question marks (?)
- asterisks (*)
- 以 "-" 開頭
對付它們有以下方法
spaces:
rm "file name"
以 "-" 開頭:
rm ./-filename
rm -- -foo
dollar:
rm \$filename
backslashes:
rm \\filename
non-ascii (linux filename with question mark)
The ? is most likely another non-ASCII symbol that your terminal program is unable to display so it displays ?.
This is easily proven - you can execute touch ?.mkv and rm ?.mkv - both command execute just fine.
find . -maxdepth 1 -size 0 -exec mv '{}' _X \;