I'm trying to write a bash script where part of a directory is a long, unknown string. I know the first part of the directory name. How do I combine the known string and the wildcard in the path? As of now, I have:
ID=$1;
IMP="adam@ocelot.cs.edu:/data/"$ID"/EER_DATA/$ID"*"/ImpostorScores.txt"
but this passes a literal *
.
Best Answer
There are several options,
bash
apply the defaultFOO=/*/passwd
glob on that exported filesystem path. (ZSH has a${~spec}
glob substitution parameter expansion, otherwise see your shell's manual.)ssh host 'echo /*/passwd'
scp host:/\*/passwd .
Some of these options are prone to race conditions should the filename change between when the glob is done and any subsequent steps involving that (possibly changed) filename.