apan
apan

Reputation: 461

Need to find all the files from the huge list of directories in bash

Need to find all the files in a huge list of directories with some criteria such as all files starts with "sam" and ends with ".gz".Can someone help me with this in bash?

Upvotes: 0

Views: 40

Answers (1)

Alex Forbes
Alex Forbes

Reputation: 3589

From bash you can call the find command like so:

find . -name 'sam*.gz'

If it's a list of directories, you can iterate over them with a for loop:

for d in $DIRS; do
    find $d -name 'sam*.gz'

Where $DIRS contains a space-separated list, i.e.:

DIRS="dir1 dir2 dir3"

Upvotes: 1

Related Questions