Last active
April 30, 2020 09:52
-
-
Save lpiot/6bde0d875f97331d6b82f21d151ec3d0 to your computer and use it in GitHub Desktop.
SHELL - How-to convert a string with line breaks into a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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