I have practiced
for flow control, referencing a sample script like;
if [ $(id -u) = "0" ]; then dir_list="/home/*" else dir_list=$HOME fi for home_dir in $dir_list; do
The above is partly quoted lines from "Flow Control - Part 3" http://linuxcommand.org/lc3_wss0130.php
Then,to check how the wildcard in a variable behaves in
for flow control, I tried the lines below;
#!/bin/bash binlist="~/bin/*" for i in $binlist; do echo $i done
I wanted the wildcard to expand and all files in
~/bin/ to be displayed as outputs, but it did not happen. The output is just
If I do not use the variable, and directly assign
~/bin/* into the list of
for, what I expect happens, all files in
~/bin/ are displayed.
How can I enable for a wildcard in variable to expand?
Or am I misunderstanding what the sample code of the reference site intends?
Thank you for your reading my question!