TMPLT={aaaa,bbbb}Files.txt => "ls $TMPLT" doesn't work

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
Spendius [ Do, 03 Januar 2008 14:42 ] [ ID #1898550 ]

Re: TMPLT={aaaa,bbbb}Files.txt => "ls $TMPLT" doesn't work

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[ [at] ]}"

Please note that all that is non standard syntax.

Standardly:

set -- aaaaFiles.txt bbbbFiles.txt
ls -d -- "$ [at] "

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
Stephane CHAZELAS [ Do, 03 Januar 2008 14:49 ] [ ID #1898551 ]

Re: TMPLT={aaaa,bbbb}Files.txt => "ls $TMPLT" doesn't work

On 2008-01-03, Spendius <spendius [at] 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.
Bill Marcum [ Do, 03 Januar 2008 17:04 ] [ ID #1898556 ]
Linux » comp.unix.shell » TMPLT={aaaa,bbbb}Files.txt => "ls $TMPLT" doesn't work

Vorheriges Thema: loading shared libraries: libstdc++.so.6
Nächstes Thema: (screen) problem with terminal wraparound