Clyde E. Boom asked: The Linux Echo Command
The echo command is used (among other things) to display something on the screen.
You can use this command in a Linux script or program to show information about what it is doing. This is useful for putting comments in a program to display its progress and debug problems with it.
Linux Commands Training Tips: A script is a text file that is given a name and contains a series of repeatedly used commands. To repeat them, you just type in the name of it and press Enter!
You can also use the echo command to prompt users for information and show the settings of an environment variable.
The Linux echo command below shows the contents of the variable named LOGNAME, which holds the name of the current user.
$ echo $LOGNAME
When you’re logged in as cwest and run:
echo $HOME you see the output of:
/home/cwest.
And the command:
echo ~ also displays this same output because the
~ represents the full path to the home directory of the user.
Example of the echo Command in a Linux ScriptAs another example, every time a Red Hat or Fedora Linux system boots, the following text appears on the screen:
Press ‘I’ to enter interactive startup.When a system boots, the
rc.sysinit script file is run. It contains the following echo command, which causes the above text to appear on the screen:
echo -en $”ttPress ‘I’ to enter interactive startup.”When using echo, the text to be output is prefixed with a $ dollar) sign.
Caffeinated Content for WordPress
Related Posts
No comments yet.