find and delete files with non-ascii names

前端 未结 5 2056
天涯浪人
天涯浪人 2020-12-29 05:32

I have some old migrated files that contain non-printable characters. I would like to find all files with such names and delete them completely from the system.

Exam

5条回答
  •  不思量自难忘°
    2020-12-29 06:26

    Based on this answer, try:

    LC_ALL=C find . -regex '.*[^ -~].*' -print # -delete
    

    or:

    LC_ALL=C find . -type f -regex '*[^[:alnum:][:punct:]]*' -print # -delete
    

    Note: After files are printed right, remove the # character.

    See also: How do I grep for all non-ASCII characters.

提交回复
热议问题