Global Expressions

by Sanju 2009-11-03 13:21:20

GLOBAL EXPRESSIONS

Global expressions are mostly used in combination with the command "ls" ( list files ).

I suppose you know that the "*" sign is a wild-card and can stand for one or more characters. The "?" is a wild-card for only 1 character. The "!" excludes the characters that follow.

Examples

$ ls [a-e]*

This will only list the files that start with a, b, c, d or e. ( Not A or B ! )

$ ls [a-eA-E]*

Will do the same but then also A, B ,C ,D and E

$ ls *[a-e]us

The files that end with: aus, bus, cus, dus and eus

$ ls ?[a-e]re

Will show the files; dare, acre, mere, bare, . . . etc.

$ ls *[!a-b]re

Shows files that end with "re", but not the ones on "are" or "bre"

$ ls *.{jpg,png,gif}

List all the files that end with .jpg, .png and .gif

Notice the difference in { } and [ ] !!!

Tagged in:

1025
like
0
dislike
0
mail
flag

You must LOGIN to add comments