|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
How could I get the following gimmick to work please ?: $ ls {aaaa,bbbb}Files.txt does return me the list 'aaaaFiles.txt' and 'bbbbFiles.txt', but when I assign the string "{aaaa,bbbb}Files.txt" to a variable and want to 'ls' this variable it tells me "no such file or directory" What kind of syntax/other command could I use ? Thanks a lot. Sp |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Thu, 3 Jan 2008 05:42:46 -0800 (PST), Spendius wrote:
> Hi, > How could I get the following gimmick to work please ?: > $ ls {aaaa,bbbb}Files.txt > does return me the list 'aaaaFiles.txt' and 'bbbbFiles.txt', > but when I assign the string "{aaaa,bbbb}Files.txt" to a > variable and want to 'ls' this variable it tells me > "no such file or directory" > > What kind of syntax/other command could I use ? [...] files=({aaaa,bbbb}Files.txt) ls -d -- "${files[@]}" Please note that all that is non standard syntax. Standardly: set -- aaaaFiles.txt bbbbFiles.txt ls -d -- "$@" or: files=$( printf '%sFiles.txt\n' aaaa bbbb ) IFS=' ' set -f ls -d -- $files (which supposes none of the file names contain newline characters (here used as separator when splitting $files)). -- Stephane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2008-01-03, Spendius <spendius@muchomail.com> wrote:
> > > Hi, > How could I get the following gimmick to work please ?: > $ ls {aaaa,bbbb}Files.txt > does return me the list 'aaaaFiles.txt' and 'bbbbFiles.txt', > but when I assign the string "{aaaa,bbbb}Files.txt" to a > variable and want to 'ls' this variable it tells me > "no such file or directory" > > What kind of syntax/other command could I use ? > eval ls $TMPLT If you use this in a script, make sure you have a #! line so the script is interpreted by the correct shell. |
|
![]() |
| Outils de la discussion | |
|
|