查找父目录中多个目录中的所有文件名

时间:2014-06-11 06:54:48

标签: bash grep find


我有一个父目录说parentparent内有多个目录,名为child-1child-2,...在包含子目录的父目录中,我想查找扩展名为*.txt的所有文件。
我该怎么办?
谢谢。

2 个答案:

答案 0 :(得分:1)

运行以下find命令查找父目录(包括子文件夹)中的.txt个文件

find . -mindepth 1 -type f -name "*.txt"

OR

find /path/to/parent -mindepth 1 -type f -name "*.txt"

答案 1 :(得分:0)

使用find命令说,

find $path/parent/ -name "*.txt" -print 2>/dev/null

     1st argument: path where files needs to be searched
     2nd argument: name or pattern of files
     3rd argument: printing the output
     4th argument: 2>/dev/null :dump the error dustbin /dev/null
相关问题