Linux程序员

linux环境下删除包含特殊字符的文件或目录

2016-06-08  本文已影响487人  蓝色瓦力

最近把一些客户数据通过scp上传到阿里的服务器,结果解压后发现目录全是中文名,我们的服务器不支持中文显示和输入,所以文件夹名是一串问号,想进去或者直接删除都不行。Google之后发现了一个办法不错,mark并分享一下。

Remove file by an inode number

The -i option to ls displays the index number (inode) of each file:

ls -li
Use find command as follows to delete the file if the file has inode number 4063242:

$ find . -inum 4063242 -delete
OR
$ find . -inum 4063242 -exec rm -i {} ;

Source: https://www.linux.com/blog/linux-shell-tip-remove-files-names-contains-spaces-and-special-characters-such

上一篇 下一篇

猜你喜欢

热点阅读