[sf-lug] path name expansion

Alex Kleider akleider at sonic.net
Fri Aug 19 10:16:16 PDT 2016


On 2016-08-19 04:05, Michael Paoli wrote:
> bash(1):
> 
> Brace expansion is a mechanism by which arbitrary strings may be gener-
> ated.  This mechanism is similar to pathname expansion, but  the  file-
> names generated need not exist.
> 
> After word splitting, unless the -f option has  been  set,  bash  scans
> each  word  for the characters *, ?, and [.  If one of these characters
> appears, then the word is regarded as a pattern, and replaced  with  an
> alphabetically  sorted list of filenames matching the pattern (see Pat-
> tern Matching below).  If no matching  filenames  are  found,  and  the
> shell  option  nullglob is not enabled, the word is left unchanged.
> 
> Note specifically, "If no matching filenames are found" ...
> "the word is left unchanged".

The above clarifies it, thank you.



> Among other things, you could do something like:
> $ (for d in Dir*/; do touch "$d"file{1..3}; done)

snip

> Or you could do something like:
> $ touch Dir{A..C}/file{1..3}
> e.g.:
> $ ls
> $ mkdir Dir{A..C}
> $ touch Dir{A..C}/file{1..3}

Nice- does just what I wanted- just that it takes two lines rather than 
one.

> And no brace expansion in dash(1) - you're probably using bash(1).
> What do these show you?:
> $ ls -l /proc/$$/exe
alex at X301n3:~/Test$ ls -l /proc/$$/exe
lrwxrwxrwx 1 alex alex 0 Aug 16 07:51 /proc/6601/exe -> /bin/bash

> $ set | grep '^BASH_VERSION='
alex at X301n3:~/Test$ man set
No manual entry for set
alex at X301n3:~/Test$ which set
alex at X301n3:~/Test$ file set
set: ERROR: cannot open `set' (No such file or directory)
The command 'set' seems not to be available on my system but:
alex at X301n3:~/Test$ printenv | grep '^BASH_VERSION='
alex at X301n3:~/Test$ printenv | grep SHELL
SHELL=/bin/bash
makes your point.


> And "default" shell?  Default in what context?
> Default shell if not specified when creating account?
> Default shell on user account(s) on live DVD, or when created with
> default install?
> Or default shell if the shell field of /etc/passwd is null?
> All three of those defaults may be distinct - and there are other
> contexts for what is the default shell - e.g. file readable and 
> executable,
> but not binary, and lacking #! notation on first line - what 
> interpreter will
> be used on the file by default if one attempts to execute the file?  
> That may
> also depend upon the interpreter under which one attempts to execute 
> the file.
> 
> RTFM - Read The Fine Manual.  :-)

Always happy to RTFM! Regrettably it's not always clear which (parts of 
which) manual to read.  Hence my constant gratitude to members of the 
list willing to chime in and help.

Thanks for the help.
Alex

sent from my current gizmo:-)





More information about the sf-lug mailing list