back to

2021-07-27 - here documents & here strings

this is a bash post. i knew about here documents in bash, but i didn't know what it is called. a here document is something like this:

it tells bash to redirect the current input to stdin, until you reach the token defined right after the `<<`. but the other day i wanted to replace stdin with the content of an environment variable. the approach i came up with was:

but there is another, arguably better, way to do that with a here string:

i never noticed the `<<<` here string syntax before, so i thought i'd share. you can find some more information on here strings and here documents here: