Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In bash, what's the regular expression to list two types of files?

Tags:

regex

bash

A directory contains .zip and .rar files, and files of other type.

To list only .rar and .zip files, there is ls *.zip *.rar

In bash, how to match both types with one regex?

like image 241
galath Avatar asked May 24 '11 11:05

galath


1 Answers

Do you really want a regular expression?

This uses * ("globbing") and {[...]} ("brace expansion").

$ ls *.{zip,rar}

See also this question for many, many more shortcuts.

like image 117
Johnsyweb Avatar answered Sep 19 '22 05:09

Johnsyweb