rudib
rudib

Reputation: 227

Bash script in bash variable

I have a bash script that arrives like:

SCRIPT=$(curl .... | parsing...)

echo $SCRIPT > myfile

But when I try to echo it in a file, some parts get evaluated. (Variables are substituted if any are defined, the * character is replaced by all files in the working directory, etc...)

Can I prevent bash from evaluating any content of a variable, while still echoing?

Upvotes: 0

Views: 139

Answers (1)

Sjon
Sjon

Reputation: 5155

Yes, use double quotes for that. I'll demonstrate:

$ x='*'

$ echo $x
..list of files..

$ echo '$x'
$x

$ echo "$x"
*

Upvotes: 1

Related Questions