I'm looking for a simple way to include multi-line scripts inline in documentation to make it transparent what each step does.
This works
echo "echo 1234" | bash
So does this
echo 'for N in 1 2 3; do echo $N; done' | bash
However, I'd like to use something like this (which does not work):
echo <<EOF | bash
for N in 1 2 3; do
echo "N is ${N}"
done
EOF
Update, the closest working solution so far is:
cat <<EOF|bash
for N in 1 2 3 4; do
echo "N is now \$N"
done
EOF
Ideally though I'd like to not have to escape the \$N
A correct solution will not:
- use tools not installed default debian config
- involve a temp file
- downloaded the script (
curl -o - htpp://blah.com/script | bash
etc )
Ideally it's something something the reader can copy paste, press enter, and will execute without further action.