2

I'm creating a bash script that will run only once, but after that, it'll create another bash script. I've tried to use CAT EOT, but the problem is that, instead of copy/paste the text inside the new bash, it "executes" all variables inside.

E.g.: instead of write "date=$(date +%d)", it is writing "date=18" in the new archive.

How can I make it copy/paste, instead of execute the command?

1
  • 2
    It's called a bash script or just script, not a bash. Commented Sep 19, 2016 at 0:45

1 Answer 1

8

To prevent variables from being expanded in a here-doc, put quotes around the token.

cat <<'EOT'
This is a here-doc
that contains $variable
EOT
Sign up to request clarification or add additional context in comments.

1 Comment

It worked, thanks a lot!!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.