ATTN:贝壳之神;)
我似乎无法弄清楚如何删除OSX上文件名中带有unicode字符0x2400的文件(例如:␀.test)。
它本身不是NULL字符,而是null"的"符号。 (见:http://unicodelookup.com/#null/1)
脚本 - 如何重现
#!/usr/bin/env bash
dir="${HOME}/test_dir"
# Create Directory: ~/test_dir
if [ ! -d "${dir}" ]; then
printf "\nCreating Directory: ${dir}\n"
mkdir ${dir}
fi
# Create our character
char=$'\xE2\x90\x80'
# Create filename
file="${dir}/${char}.test"
# Create the File
printf "\nCreating File: ${file}\n"
touch ${file}
删除文件... NOPE!
# Attempt 1 - Delete File
printf "\nDeleting File: ${file}\n"
rm -rf ${file}
删除整个目录... NOPE!
# Attempt 2 - Delete Directory
printf "\nDeleting Directory: ${file}\n"
rm -rf ${dir}
通过inode删除文件... NOPE!
# Attempt 3 - Delete File
inode=$(ls -i1 ${dir} | awk '{print $1}')
printf "\nDeleting via Inode: ${inode}\n"
find ${dir} -inum ${inode} -exec rm -i {} \;
整个脚本应输出如下内容:
Creating File: /Users/bsmith/test_dir/␀.test
Deleting File: /Users/bsmith/test_dir/␀.test
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
Deleting Directory: /Users/bsmith/test_dir/␀.test
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
rm: /Users/bsmith/test_dir: Directory not empty
Deleting via Inode: 68592933
remove /Users/bsmith/test_dir/␀.test? y
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
答案 0 :(得分:0)
这个命令对我有用:
rm ?.test
但遗憾的是,它很可能不适合你。
这是osx的已知错误:
Is it impossible to delete/move a file named “␀” on mac?
Rename folder with odd characters
可以肯定的是,从带有某些Linux操作系统的笔式驱动器启动,将文件系统挂载到此类Linux中,然后擦除该文件。可以确定具有此类名称的文件可以在Linux中删除。