In a directory, I have files like
lazer_100506
lazer_100707
lazer_091211
lazer_110103
lazer_100406_temp
lazer_100622#delete
etc
How can I get a listing of only the first four files?
$ ls lazer_......
ls: lazer_......: No such file or directory
$
|
|
|
There are multiple methods:
|
|
|||
|
@Lazer What you're experiencing is the difference between globbing and regular expressions. Unfortunately, these two grammars share some of the same symbols but they have very different meanings. In regex, the . means any single character but with globs, this is specified by ?. Shells understand globbing, not regex. – SiegeX Jan 8 '11 at 21:45 |
||
|
|
As pointed out by SiegeX, Shell alone does not understand regular expressions.
If you want a precise filter of your files, you must use regular expressions and hence use a command like Here, the files you want to list begin with
This regex works the same as Regular expressions with
|
|||
|
|