Showing posts with label exclude. Show all posts
Showing posts with label exclude. Show all posts

Sunday, May 30, 2010

Exclude Pattern Matching in Linux

If you are using bash shell you can use extended pattern matching functionality.
For example you want to list files in a directory which does not match with certain pattern. Here is how you do it.

$ shopt extglob
extglob off
$ shopt -s extglob # Enable extglob
$ ls -l !(*.foo)

You can also use it with other commands, such as rm, cp, etc.