Stu*_*ner 6 command-line filenames synology
首先了解一些背景信息:我正在尝试将 Synology NAS 上的未加密共享文件夹转换为加密文件夹,但看到此错误:
所以我想找到有问题的文件,以便我可以重命名它们。我想出了以下grep
命令:grep -rle '[^\ ]\{143,\}' *
但它输出路径大于 143 个字符的所有文件:
#recycle/Music/TO SORT/music/H/Hooligans----Heroes of Hifi/Metalcore Promotions - Heroes of Hifi - 03 Sly Like a Megan Fox.mp3
...
Run Code Online (Sandbox Code Playgroud)
我想要的是让 grep 拆分/
然后执行搜索。关于执行此操作的有效命令的任何想法(目录很容易包含数十万个文件)?
ste*_*ver 12
尽管 GNU 'findutils-default' 正则表达式语法不提供{n,m}
间隔量词,但如果您选择不同的,您可以-regex
在 GNU 中使用测试,例如:find
regextype
find . -regextype posix-extended -regex '.*/[^/]{143,}$'
Run Code Online (Sandbox Code Playgroud)
或者
find . -regextype egrep -regex '.*/[^/]{143,}$'
Run Code Online (Sandbox Code Playgroud)
或者
find . -regextype posix-basic -regex '.*/[^/]\{143,\}$'
Run Code Online (Sandbox Code Playgroud)
等。可能还有其他regextypes
支持{n,m}
间隔,无论是否有转义。
与将结果通过管道find
传送到单独的grep
命令相比,这将匹配换行符(即,find
正则表达式与它们的同名不同.
,默认情况下匹配换行符)。