Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of using newline characters in Bash Shell

Shulou Source: shulou.com Published: 2022-06-02 04:36:07 09月11日 Update

Editor to share with you how to use newline characters in Bash Shell, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Let's first take a look at the orders.

Use the following command to print newline characters in the bash shell script.

Printf "first line\ nsecond line\ n"

The usage of\ nin bash

\ n (newline) is used as a newline character for Unix-based systems. The following is a simple example of using newline characters in a bash shell script.

String in double quotation marks:

$echo-e "This is First Line\ nThis is Second Line"

String in single quotation marks:

$echo-e'This is First Line\ nThis is Second Line'

String with $prefix:

$echo $'This is First Line\ nThis is Second Line'

Use the printf command:

$printf "This is First Line\ nThis is Second Line" above is all about the method of using newline characters in Bash Shell. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Newline characters commands characters strings methods content quotation marks are in articles scripts not much prefixes most more knowledge examples systems industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia Apple vpn MySQL