Skip to content

Instantly share code, notes, and snippets.

@kennyyu
Created November 6, 2021 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennyyu/a727cb12207b501f83bfa07429c5480b to your computer and use it in GitHub Desktop.
Save kennyyu/a727cb12207b501f83bfa07429c5480b to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
CONTENTS=$(cat <<EOF
foo
bar
baz
EOF
)
sudo echo "$CONTENTS" > /tmp/my_file.txt
@kennyyu
Copy link
Author

kennyyu commented Nov 6, 2021

$ /tmp/foobar.sh
++ cat

  • CONTENTS='foo
    bar
    baz'
  • sudo echo 'foo
    bar
    baz'

$ cat /tmp/my_file.txt
foo
bar
baz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment