1

I have a value stored in a variable that I want to use as part of a wildcard, like this:

set extension (somecommand)
cp *$extension ~/filezone

But the * prevents the variable from being dereferenced. How can I use the value stored in a variable as part of a wildcard?

1 Answer 1

2

Your somecommand is probably returning nothing. Check count $extension, and I bet it's zero.

This does work:

$ touch a.foo b.foo c.bar
$ set extension foo bar
$ ls *$extension
a.foo  b.foo  c.bar

But if your variable is an empty list, *$extension expands into nothing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .