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"/*)[@]"
FOO="foo bar"
;wc "${FOO}"/*
should skip the intermediate variable – RobotJohnny Sep 21 '18 at 08:50