0

If I have a directory wibble, the following command does what I want:

WIBBLE=wibble
wc $WIBBLE/*

If I have a directory foo bar, the following command does what I want:

wc foo\ bar/*

But this doesn't do what I want

FOO="foo bar"
wc $FOO/*

I get:

wc: foo: No such file or directory
wc: bar/*: No such file or directory

I've tried everything I could find here, but nothing wants to work for me! What am I missing? I do not want a solution using for as I want to pipe the output from wc to other commands.


Examining the dup, this works:

FOO="foo bar"
BAR=("$FOO"/*)
wc "${BAR[@]}"

My question now becomes "Can I avoid the intermediate variable?". This just prints the straightforward expansion:

FOO="foo bar"
wc "("$FOO"/*)[@]"
Ken Y-N
  • 253
  • If you have a completely new question. Please feel free to ask it with all information necessary. Doing edit that changes completly the scope of your question invalidate answer and the whole point of a Q&A site. – Kiwy Sep 21 '18 at 08:48
  • FOO="foo bar" ; wc "${FOO}"/* should skip the intermediate variable – RobotJohnny Sep 21 '18 at 08:50

0 Answers0