[英]How to use find + regex to match files and return only unique directories containing said files?
此find命令匹配我正在搜索的文件:
find / -type f -regextype sed -regex ".*/g\.[0-9]\{4\}.*"
如何進入列出包含這些文件的唯一目錄名稱的下一步? (我不需要顯示所有文件。)
將輸出傳遞給刪除文件名的sed
命令,然后使用uniq
刪除重復項:
find / -type f -regextype sed -regex ".*/g\.[0-9]\{4\}.*" | sed 's|/[^/]*$||' | uniq
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.