usha
usha

Reputation: 29349

how to recursively list files from a folder?

'ls dir1/*/.ext' just lists all the files with just one level of nesting. What is the command to recursively list all the files with any level of nesting in linux?

Upvotes: 0

Views: 626

Answers (4)

davids
davids

Reputation: 6371

You could use find:

find .

That command would list everything under the current folder

Upvotes: 0

Martin Atkins
Martin Atkins

Reputation: 74084

The find command is one way to do this:

find dir1 -name .ext

The -name operator can take a wildcard to match with, but it's important to quote the wildcard expression so that it won't be expanded by your shell before calling into find:

find dir1 -name "*.ext"

The find command has many operators that can do various different tests on the files in the directory, of which -name is just one example. Consult the find manual page for more information.

Upvotes: 1

Martinsos
Martinsos

Reputation: 1693

To list folder recursively:

ls -R

Upvotes: 0

ugoren
ugoren

Reputation: 16441

ls -R dir1

Or:

find dir1 -name "*.ext"

Upvotes: 4

Related Questions