Reputation: 149
Consider the following bash scripts:
#!/bin/bash
cat << EOF > file
$@
VAR=`cat somefile`
EOF
I want to write a file called file
such that $@
is evaluated but cat something
is not. In other words I want the output to look like this:
Arg1 Arg2 Arg3 Arg4
VAR=`cat something`
If I use 'EOF'
instead of EOF
, then nothing gets evaluated, but I want $@
to be evaluated.
Upvotes: 1
Views: 577
Reputation: 741
Have you tried escaping the characters? Using "\`":
cat <<EOF > file
$@
VAR=\`cat testfile\`
echo \$VAR
> EOF
Here is the file content:
cat file
VAR=`cat testfile`
echo $VAR
Then execute it:
./file
Hi!
Upvotes: 4