Mailinglist Archive: opensuse (880 mails)

< Previous Next >
Re: [opensuse] Back to the basics (bash)
Ciro Iriarte said the following on 08/11/2013 05:29 PM:
Thanks Berny, but why [] doesn't work in both cases like {}?, {} works
for file listing and for file creation... That's why I was expecting
[] to work the same way (my bad?)

The "[]" is pattern matching for a set of characters
The "{}" is enumeration for a set of file names

You would have to do

ls {1,2,3)b

to match files 1b, 2b and 3b.

Enumeration means that the names are generated by shell expansion regardless of whether the files exist or not. So you might

$ ls {1,2,3}b
ls: cannot access 1b: No such file or directory
ls: cannot access 3b: No such file or directory

if only "2b" existed.
Or worse
mkdir {1,2,3}b
mkdir: cannot create directory ‘2b’: File exists

and now

$ ls -ld {1,2,3}b
drwxr-xr-x 1 anton users 0 Aug 11 17:35 1b
-rw-r--r-- 1 anton users 0 Aug 11 17:34 2b
drwxr-xr-x 1 anton users 0 Aug 11 17:35 3b

How long did the whining go on when KDE2 went on KDE3?

The only universal constant is change. If a species can not adapt it
goes extinct. That's the law of the universe, adapt or die.
-- Billie Walsh, May 18 2013
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >