find files with non-ascii chars in file name [closed]

孤人 提交于 2019-12-08 13:58:06

问题


Is there a way I can find files with non-ascii chars? I could use a pipe of course - and filter the files with perl, but for efficiency I'd like to set it all in find. I tried the following:

find . -type f -name '*[^[:ascii:]]*'

it doesn't work at all.

Edit:

I'm now trying to make use of

find . -type f -regex '.*[^[:ascii:]].*'

It is an emacs regexp and it has [:ascii:] class. But the expression I'm trying to use doesn't work.

Edit 2:

LC_COLLATE=C find . -type f -regex '.*[^!-~].*'

matches files with non-ascii chars (a complete voodoo...). But also matches files with a space in the name.


回答1:


This seems to work for me in both default and posix-extended mode:

LC_COLLATE=C find . -regex '.*[^ -~].*'

There could be locale-related issues, though, and I don't have a large corpus of non-ascii filenames to test it on, but it catches the ones I have.



来源:https://stackoverflow.com/questions/10796297/find-files-with-non-ascii-chars-in-file-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!