Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Echo Command Examples     - Linux command Detailed chpasswd bulk edit user password (Linux)

- Java data structures - the single linked list LinkedList linear table (Programming)

- Android to determine whether the device to open WIFI, GPRS data connection (Programming)

- Advanced permissions Linux file system settings (Linux)

- How to modify the Ubuntu terminal user name changed to red color (Linux)

- FastDFS installation and deployment (Server)

- Getting Started with Linux: Learn how to install and access CentOS 7 Remote Desktop on a VPS (Server)

- Linux installed and tested the deployment of Kafka distributed cluster (Server)

- Learning the Linux powerful network management capabilities (Linux)

- RabbitMQ user roles and access control (Linux)

- MariaDB database storage path modify configuration issues (Database)

- Linux server network penetration testing (Linux)

- Towards Docker (Server)

- The free command in Linux (Linux)

- Linux install deploy Ansible (Linux)

- Install Java JDK 8 in CentOS 7 / 6.5 / 6.4 (Linux)

- 30 Practical Linux system administrators will learn the command (Linux)

- Using shell users or virtual users to login to pureftpd (Linux)

- Unix / Linux commonly used to clean up disk space command (Linux)

- Ubuntu installation 2.10.x version of Scala (Linux)

 
         
  Echo Command Examples
     
  Add Date : 2018-11-21      
         
         
         
  Echo command is a built-in shell command, variable values for display or print a line of text.

echo command plays an important role in building a shell script.

grammar:

# Echo [Options] [String]
Square brackets are optional items. It can be defined as a finite sequence of strings (e.g., letters, numbers, symbols, punctuation) characters.

When the echo command without any options or strings, it will return a blank line on the screen, followed by a line change to keep up with the command prompt. This is because pressing the Enter key is to send a signal to the system in order to start a new line, and repeat the echo signal.

Options:

-n do not output a new line-derived
-e enable interpretation of backslash escapes
-E Disable interpretation of backslash escapes (default)
If you use the -e option, you can use the following escape sequences:

\ Backslash
\ A warning (BEL)
\ B backslash
\ C no further output
\ E Escape
\ F feed
\ N new line
\ R newline character
\ T horizontal tab
\ V vertical tab
\ 0NNN NNN octal byte value represented by (1-3 digits)
\ XHH NNN byte hexadecimal value represented by (1-2 digits)

Example: A value of 1 displays system-defined variables

Use the set command, we can list the system-defined variables. And to print the values of these variables, we can use the echo command:

jack @ localhost: ~ $ echo $ USER
jack
jack @ localhost: ~ $ echo $ HOME
/ Home / jack
Example: 2 shows the value of the user-defined variables

jack @ nextstep4it: ~ $ var1 = `date`
jack @ nextstep4it: ~ $ echo "Today's date time is: $ var1"
Today's date time is: Mon Jul 28 13:11:37 IST 2014
Example: 3 displays the text string

jack @ nextstep4it: ~ $ echo "Hi this echo command testing"
Hithis echo command testing
Example: 4 backslash in echo command

jack @ nextstep4it: ~ $ echo -e "Ubuntu \ bis \ bthe \ bbest \ bDesktop \ bOS"
The above command will print:

UbuntuisthebestDesktopOS

Example: 5 spaces with tabs in the echo command

nextstep4it @ nextstep4it: ~ $ echo -e "Ubuntu \ tis \ tthe \ tbest \ tDesktop \ tOS"
The above command will display the following output:

Ubuntu is the best Desktop OS

Example: 6 Use vertical tab in the echo command

jack @ nextstep4it: ~ $ echo -e "Ubuntu \ vis \ vthe \ vbest \ vDesktop \ vOS"
Ubuntu
is
the
best
Desktop
OS
Example: 7 Set command echo color output

echo command to change the font type, font color and font background color, the escape sequence \ 033 can be used to change the font attributes. To escape sequence to take effect, you must use the -e option. Listed below are some of the escape codes:

[0m: Normal
[1m: Bold
[4m: Font Underline
[7m: reverse the foreground and background colors
[8m: invisible characters
[9m: interbank Font
[30m: Grey Font
[31m: red font
[32m: Green Font
[33m: Brown Font
[34m: blue font
[35m: Purple Font
[36m: light blue font
[37m: light gray font
[38m: black font
[40m: Black background
[41m: red background
[42m: green background
[43m: brown background
[44m: blue background
[45m: purple background
[46m: light blue background
[47m: light gray background
The following command will be printed in red.

jack @ nextstep4it: ~ $ echo -e "\ 033 [31mMagic of Linux \ 033 [0m"
Magic of Linux
The following command will appear in bold red background and prints out "Magic of Linux".

nextstep4it @ nextstep4it: ~ $ echo -e "\ 033 [1m \ 033 [41mMagic of Linux \ 033 [0m"
Magic of Linux
     
         
         
         
  More:      
 
- Use Observium to monitor your network and servers (Server)
- Oracle physical storage structure outline (Database)
- Elementary OS Freya global menu (Linux)
- Ubuntu install perfectly handsome terminal Guake 0.8.1 (Linux)
- DM9000 timing settings (Programming)
- Windows using SSH management Ubuntu (Linux)
- Go build the locale under Windows (Linux)
- Linux Getting Started tutorial: Borrow Windows fonts in Ubuntu 14.10 (Linux)
- Linux C programming and Shell Programming in the development of practical tools similarities summary (Programming)
- Ubuntu 14.10 Apache installation and configuration (Server)
- Several back door and log tool under Linux (Linux)
- Docker startups use continuous integration deployment (Server)
- Android memory optimization of the disk cache (Linux)
- Ubuntu system process is bound CPU core (Linux)
- Ora-00020: maximum number of processes (500) exceeded (Database)
- Deploy Mono 4 and Jexus 5.6 on CentOS7 (Server)
- Linux system security reinforcement system by masquerading method (Linux)
- The Linux OOM Terminator (Server)
- Linux system security configuration Collection (Linux)
- Linux, how to filter, split, and merge pcap file (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.