Echo command
In Linux, the echo command can be used for displaying a line of string/text that is passed as the arguments. This command is a built-in that is mostly and widely used in various batch files and shell scripts to outcome status test to a file and screen.
Syntax of the echo command
Implementations of the echo command
The echo command exists in SymbOS, KolibriOS, HP MPE/iX, ReactOS, Microsoft Windows, IBM OS/2, Digital Research FlexOS, Acorn Computers Panos, Microwave OS-9, Zilog Z80-RIO, MetaComCo TRIPOS, TSC FLEX, Multics, Unix-like and Unix operating systems.
Several shells including every Csh-like (like zsh or Bash), Bourne-like shells, and COMMAND.COM as well and cmd.exe execute the echo command as the built-in command.
The command also exists inside the EFI shell.
History of the echo command
The echo command started in Multics. Later it was specified by Doug Mcllroy in C language as the “finger exercise” and verified to be helpful. It became a part of the 2 versions of Unix.
In the 7 versions, the echo -n command replaced prompt (behaved like the echo command, however, without terminating the output along with the line delimiter).
This command began developing C escape sequences like n along with the difference that the octal escape sequences were represented as the 0ooo rather than ooo in C on UNIX/PWB and after Unix System 3.The echo command exits in 2 versions on MS-DOS.
Nowadays, various echo incompatible implementations are available on distinct operating systems (various on the similar system). By default, a few of them developing escape sequences, a few of them does not. Similarly, a few of them getting options (list of which changing with implementations), and a few of them does not.
Echo POSIX Specification leaves the nature unspecified when the initial argument is -n or other arguments include backslash characters during the specification of Unix (option XSI in POSIX) mandates the development of the sequences and doesn’t permit the option processing.
Several implementations of the echo command are not flexible inside the default platform. Due to these types of changes in nature, the echo command is examined as a non-portable command, and the command, i.e, printf is preferred rather on Unix-like systems.
Displaying a string/text:
Syntax:
Example:
Output:
Echo Command Options
There are various options available in the echo command. These options are listed and explained below:
1. b: This option is used for removing every space among the text/string.
Example:
Output:
2. c: This option is used for suppressing the trailing new line along with the ‘-e’ backspace interpretor to proceed without emitting any new line.
Example:
Output:
3. n: This option is used for creating a new line and this new line will be created from where it’s used.
Example:
Output:
4. t: This option is used for creating the horizontal tab spaces.
Example:
Output:
5. r: This option is used for carriage return along with ‘-e’ backspace interpretor to have described carriage return in the result.
Example:
Output:
6. v: This option is used for creating the vertical tab spaces.
Example:
Output:
7. a: This option is used for alert return along with ‘-e’ backspace interpretor to add sound alert.
Example:
Output:
This command if run, it will generate a bel or alert sound.
Note: Before firing, ensure to check the volume keys.
8. echo *: This option is used for printing every folder or file. It is the same as the ls command in Linux.
Example:
Output:
9. -n: This option is used for omitting echoing trailing new lines.
Example:
Output:
10. Print “Hello All”: For printing text “Hello All!” on the terminal, we can use the below command:
Example:
Output:
11. Print specific types of files: For example, if we wish to print every ‘.c’ file, we can apply the below command:
Example:
Output: