You can make use of the \n character to enter a new-line character in a bash script string. But you need to be mindful of what platform you are working on with the script. On Windows, you may need to use \r\n or rather choose $'\n' to make it platform independent.
| Platform | Newline Character | Example |
|---|---|---|
| Mac | \n | echo -e "\nHello!\nHow are you?" |
| Windows | \r\n | echo -e "\r\nHello!\r\nHow are you?" |
| Linux | \n | echo -e "\nHello!\nHow are you?" |
| Works for All | $'\n' | echo -e "Hello!"$'\n'"How are you?" |

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!