The right side of a "Variable Assignment" is considered quoted (no splitting or globing):
LESS=+'/A variable may be assigned' man bash
A variable may be assigned to by a statement of the form:
name=[value]
Word splitting is not performed, ... . Pathname expansion is not performed.
Therefore:
$ var=*
$ echo "$var"
*
To get an asterisk to expand, you need to use it un-quoted:
var="$(echo *)" ### Expand to the list of files on pwd.
In your case:
$ ID=one
$ IMP="$( echo "adam@ocelot.cs.edu:/data/$ID/EER_DATA/"*"/ImpostorScores.txt")"
$ echo "$IMP"
adam@ocelot.cs.edu:/data/one/EER_DATA/something/ImpostorScores.txt
That something will be expanded if the whole path match, that is, a tree like this actually exists:
$ tree adam@ocelot.cs.edu\:/
adam@ocelot.cs.edu:/
└── data
└── one
└── EER_DATA
└── something
└── ImpostorScores.txt
Note: I removed the second $ID
from your source, easy to re-place.
bash
does this by default e.g. forFOO=/*/passwd
. Is the path local (so an immediate glob expansion can happen) or is it remote? – thrig May 19 '16 at 22:56in the current directory and so on. The glob won't find a match and thefore remain as an asterisk. What's would you do with the
$IMP` variable if if did expand across hosts? – Petr Skocik May 19 '16 at 22:56scp
command – Adam_G May 19 '16 at 22:59$ID
in your string for$IMP
. Is that as you need it? – May 21 '16 at 04:27