I've searched everywhere. Tried echo and print. Tried single and double quotes. But I have parsed data and assigned it to a variable and would like to then evaluate it for if there is a variable within it. I will then replace the variable with a wildcard and search for the file.
Example:
var="file.$DATE.txt"
### Where it goes wrong- Needs to identify that $DATE is within the $var varaible.
test=$(echo "$var"|grep '\$')
if [[ $test ]]
then
### I would use whatever fix is discovered here as well
test=$(echo $test|sed 's/\$[a-zA-Z]*/\*/')
fi
### (Actually pulling from remote machine to local)
cat $test > /tmp/temporary.file
Here is at least one of my many failures:
PROMPT> file=blah.$DATE
PROMPT> test=$(echo "$file"|grep '\$')
PROMPT> echo $test
PROMPT>
PROMPT>
I know it has something to do with expansion, but have no idea how to work it out. Any help would be appreciated. Thanks!
$date?. For that use:var='file.$DATE.txt'. To expand date when var is used? I am sure that you need to explain what you are asking.sed 's/\${*[a-zA-Z0-9_%]*}*/\*/'