If I want files ending with .fas I know I can do the following with ls command :

ls -l /users/jenna/bio/*.fas

and this lists out all the files ending with .fas. But how can I get files ending with either .fas or .pep ?

ls -l /users/jenna/bio/(*.fas | *.pep) doesn't seem to work ? I know there might be other commands that can do this, but is there a way to make it work with ls ?

Thanks for any help !


3 Answers 3


Use this: ls -l /users/jenna/bio/*.{fas,pep}

Or this: find /users/jenna/bio -iname '*.pep' -or -iname '*.fas'

  • first my depend on shell actually, not sure it would work in busybox for example. in bash it would. Mar 30, 2016 at 18:44

The thing that's most likely to work out of the box is brace expansion. It works in bash, zsh and ksh.

ls -l /users/jenna/bio/*.{fas,pep}

(No spaces anywhere around the braces.)

In bash and ksh, this displays an error if one of the extensions isn't matched, but lists the files matching the other extension anyway. The reason for this is that brace expansion isn't a wildcard matching feature, but a textual replacement: *.{fas,pep} is converted to *.fas *.pep before the shell starts looking up files that match the patterns. In zsh, you'll get an error and the command won't run, but there's a better way: an “or” glob pattern. This one won't error out unless none of the extensions match.

ls -l /users/jenna/bio/*.(fas|pep)

Or patterns are also available with a different syntax: @(…|…); in bash, this syntax needs to be activated with shopt -s extglob, and in zsh, this syntax needs to be activated with setopt ksh_glob.

ls -l /users/jenna/bio/*.@(fas|pep)

(Some of this behavior can be configured. All my statements apply to the shells' default configuration unless explicitly specified.)


When you want to scan recursively without the annoying errors you usually get from find or ls (like: "Permission denied", "Not a directory") which can brake scripts or xargs commands, also the tree command wasn't mentioned anywhere here:

tree -fai / | grep -e ".fas$" -e ".pep$"

above I used the root /, but can be any path:

tree -fai /users/jenna/bio/ |  grep -e ".fas$" -e ".pep$""


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .