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

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

am 03.01.2008 14:42:46 von Spendius

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

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

am 03.01.2008 14:49:53 von Stephane CHAZELAS

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

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

am 03.01.2008 17:04:38 von Bill Marcum

On 2008-01-03, 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 ?
>
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.