Bash – Echo a large chunk of text to a file using Bash

bash

I need to run a Bash script that can echo a 300 lines of Groovy script to a tmp file.
What's the best way to do it ?

My current workaround is putting the script file online and download it.

Best Solution

Use the heredoc syntax to embed the other script within a shell script:

cat > file.tmp <<'endmsg'
script goes here...
endmsg