Skip to content

Instantly share code, notes, and snippets.

@lpiot
Last active April 30, 2020 09:52
Show Gist options
  • Select an option

  • Save lpiot/6bde0d875f97331d6b82f21d151ec3d0 to your computer and use it in GitHub Desktop.

Select an option

Save lpiot/6bde0d875f97331d6b82f21d151ec3d0 to your computer and use it in GitHub Desktop.
SHELL - How-to convert a string with line breaks into a file
# source: https://stackoverflow.com/questions/52065016/how-to-replace-n-string-with-a-new-line-in-unix-bash-script
# Works everywhere
foo='1\n2\n3'; echo "${foo//'\n'/$'\n'}"
# With bash 4.4 and upper
foo='1\n2\n3'; echo "${foo@E}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment