类似于find . <...>
,但任何 shell 方法(包括其他语言)都可以。
答案1
起初我认为这是不可能的:
$ find -regextype help
find: Unknown regular expression type ‘help’; valid types are ‘findutils-default’, ‘awk’, ‘egrep’, ‘ed’, ‘emacs’, ‘gnu-awk’, ‘grep’, ‘posix-awk’, ‘posix-basic’, ‘posix-egrep’, ‘posix-extended’, ‘posix-minimal-basic’, ‘sed’.
因此出现了python:
#!/usr/bin/env python3
import os
import os.path
import argparse
parser = argparse.ArgumentParser(description="List entries containing characters in unicode private use areas")
parser.add_argument("path", help="starting point")
args = parser.parse_args()
pua = (range(0xE000,0xF8FF+1),range(0xF0000,0xFFFFD+1), range(0x100000,0x10FFFD+1))
for (dp,dn,fn) in os.walk(args.path):
for n in sorted(fn+dn):
f = False
for c in n:
for r in pua:
if ord(c) in r:
f = True
print(os.path.join(dp,n))
break
if f:
break
并发现stackoverflow:Linux $FIND 和 Unicode 字符范围的十六进制表示法?, 这:
find . -print0 |
grep -zP '[\x{E000}-\x{F8FF}\x{F0000}-\x{FFFFD}\x{100000}-\x{10FFFD}][^/]*$' |
tr "\0" "\n"
我确实尝试过\p{InPrivate_Use_Area}
,但是会产生:
grep: unknown property name after \P or \p