Reputation: 16697
I can find plenty of answers which uses echo
, pipes |
and sed
for that purpose, but I would like to avoid them. So looking for some direct substitution.
I would like to define env var and reuse it inside the character string passed to application command line argument, i.e. Rscript -e '...'
.
Below is what I've tried without success.
Rscript -e 'cat("hello\n")'
#hello
export ASD="HELLO!"
Rscript -e 'cat("$ASD\n")'
#$ASD
Rscript -e 'cat("${ASD}\n")'
#${ASD}
Rscript -e 'cat("$(ASD)\n")'
#$(ASD)
I don't want to use echo
and |
pipes as my actual -e
argument to application is much more complex.
Upvotes: 0
Views: 82
Reputation: 46836
In addition to fun with quotes, you might be able to use positional parameters. Your question fails to provide a Minimal, Complete, Verifiable Example so I can't be sure this is in line with your needs.
bash-4.3$ bash -c 'set -; echo "${0^^} ... ${1/o/0}"' hello world
HELLO ... w0rld
Upvotes: 1
Reputation: 3363
$ date > filename
$ export filename=len
$ cat 'fi'"$filename"'ame'
Sun Apr 17 16:20:20 CEST 2016
Upvotes: 0