我需要列出所有的目录路径,包括一个文本,这是他们的子目录的一部分。例如,文本是" tpcc“,我有两个路径,包括tpcc,如下所示:
/home/arghy/sampledir1/**tpcc**-uva/subdir1/subdir2
/home/arghy/sampledir2/**tpcc**-postgre/subdir1/subdir2
我希望使用命令列出这些路径,并将"tpcc“作为前面提到的文本。这是什么命令?
发布于 2019-04-30 12:01:22
您所描述的任务将是满意的。
find . -type d | grep tpcc
但这也会列出“分支”目录,而不仅仅是“叶”目录:
/home/arghy/sampledir1/tpcc-uva
/home/arghy/sampledir1/tpcc-uva/subdir1
/home/arghy/sampledir1/tpcc-uva/subdir1/subdir2
这样可以吗?还是要跳过包含更多子目录的目录?
发布于 2019-04-30 12:23:04
sudo find DIRECORY -type f -exec grep -Iq . {} \; -exec dirname {} \; | sort|uniq
检查此链接:URL
فارسی:بادستوربالامیتوانیدپاسخسوالخودرادریافتکنید。موفقوپیروزباشید
یاعلیع
https://unix.stackexchange.com/questions/516357
复制相似问题