Details: how to use Echo in Linux

Source: Internet
Author: User
Tags echo display
Article Title: Details: how to use Echo in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The following is an example to illustrate the usage (test in bash environment)

  1. echo display string

A normal string can be input directly after echo, but this will cause problems when you want to output some characters such as \ (in this way, \ is filtered out as a row operator, to Output A \ must be input \, which is similar to the requirements of C language printf output), so it is generally best to use the 'string' or "string" format, so that even \ can be output, convenient and intuitive.

# Echo hello world

Hello world

# Echo hello \ world

Hello world

# Echo hello \ world

Hello \ world

# Echo 'hello \ world' or: echo "hello \ world"

Hello \ world

  2. echo escape display: add the-e Parameter

Output multiple rows

# Echo-e 'hello \ nworld ′

Hello

World

Output ascii character: echo-e \ NNN (NNN is the octal code number of the ascii character. If it does not conform to octal, it will be printed literally)

# Echo-e '\ 61 \ 62 \ 101 \ 141 ′

1 2 A

For more details, see the following references. enjoy!

  References

Info echo and man echo:

     
      File: coreutils.info, Node: echo invocation, Next: printf invocation, 
      
Up: Printing text`echo´: Print a line of text============================`echo´ writes each given STRING to standard output, with a spacebetween each and a newline after the last one. Synopsis: echo [OPTION]... [STRING]...The program accepts the following options. Also see *Note Commonoptions::.`-n´ Do not output the trailing newline.`-e´ Enable interpretation of the following backslash-escaped characters in each STRING: `\a´ alert (bell) `\b´ backspace `\c´ suppress trailing newline `\f´ form feed `\n´ new line `\r´ carriage return `\t´ horizontal tab `\v´ vertical tab `\\´ backslash `\NNN´ the character whose ASCII code is NNN (octal); if NNN is not a valid octal number, it is printed literally.============================echo - manualECHO(1) FSF ECHO(1)NAME echo - display a line of textSYNOPSIS echo [OPTION]... [STRING]...DESCRIPTION NOTE: your shell may have its own version of echo which will supercede the version described here. Please refer to your shell´s documentation for details about the options it supports. Echo the STRING(s) to standard output. -n do not output the trailing newline -e enable interpretation of the backslash-escaped characters listed below -E disable interpretation of those sequences in STRINGs --help display this help and exit --version output version information and exit Without -E, the following sequences are recognized and interpolated: \NNN the character whose ASCII code is NNN (octal) \\ backslash \a alert (BEL) \b backspace \c suppress trailing newline \f form feed \n new line \r carriage return \t horizontal tab \v vertical tabAUTHOR Written by FIXME unknown.REPORTING BUGS Report bugs to <>.COPYRIGHT Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.SEE ALSO The full documentation for echo is maintained as a Texinfo manual. If the info and echo programs are properly installed at your site, the command info echo should give you access to the complete manual.GNU coreutils 4.5.3 February 2003 ECHO(1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.