[英]How to use find + regex to match files and return only unique directories containing said files?
This find command matches the files I'm searching for: 此find命令匹配我正在搜索的文件:
find / -type f -regextype sed -regex ".*/g\.[0-9]\{4\}.*"
How do I move to the next step of listing just the unique directory names that contain those files? 如何进入列出包含这些文件的唯一目录名称的下一步? (I don't need to display all the files.)
(我不需要显示所有文件。)
将输出传递给删除文件名的sed
命令,然后使用uniq
删除重复项:
find / -type f -regextype sed -regex ".*/g\.[0-9]\{4\}.*" | sed 's|/[^/]*$||' | uniq
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.