Best Answer: How Do You Add a New Line Character in Unix Shell Script?
Contents

If you don’t want to use echo repeatedly to create new lines in your shell script, then you can use the n character. The n is a newline character for Unix-based systems; it helps to push the commands that come after it onto a new line.

How do I add a new line in a bash script?

Uses of n in Bash

  1. String in double quote: echo -e “This is First Line nThis is Second Line”
  2. String in single quote: echo -e ‘This is First Line nThis is Second Line’
  3. String with $ prefix: echo $’This is First Line nThis is Second Line’
  4. Using printf command: printf “This is First Line nThis is Second Line”

20 апр. 2018 г.

How do I add a new line character to a string?

In Windows, a new line is denoted using “rn”, sometimes called a Carriage Return and Line Feed, or CRLF. Adding a new line in Java is as simple as including “n” , “r”, or “rn” at the end of our string.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest