Vinica
Vinica

Reputation: 61

List only certain files in a folder

I have this directory structure. How to list only files in all F40 sub sub folders in bash? Thanks

enter image description here

Upvotes: 1

Views: 219

Answers (2)

Geralt of Ravia
Geralt of Ravia

Reputation: 61

You can your xargs with find command

find DIR -type d -name F40 | xargs ls 

Upvotes: 0

Thomas Hansen
Thomas Hansen

Reputation: 777

The find command, combined with ls, can do it. For instance like this:

find DIR -type d -name F40 -exec ls {} \;

As the GNU find man page says, the find command is used for file search in a directory hierarchy.

In this case find searches the DIR folder for folders (-type d) explicitly named F40, and then it executes the ls (list directory) command to show what's inside.

Upvotes: 3

Related Questions