Chapter 5. Redirection, Pipe and Shell Script

Echo (Echo input)

Echo (Echo input)
Tag:

The echo command is used for displaying a line of text/string that is included in the argument.

echo with string

When an argument is a string, the echo command returns the string itself.

Command Line - INPUT
echo ABC
Command Line - RESPONSE
ABC

echo with variable

When an argument is a variable, use $ before the variable. the echo command returns an assigned string to the variable.

Command Line - INPUT
ABC=56
echo $ABC
Command Line - RESPONSE
56

echo with string and variable

You can connect strings and variables in the echo command.

Command Line - INPUT
ABC=56
echo ABC$ABC
Command Line - RESPONSE
ABC56

" " double quotation and ' ' single quotation

You can connect strings or variables with special characters or spaces with the " " or ' ' quotation; however, there is a slight difference.

" " double quotation

with the " " quotation, variables are converted to assigned strings.

Command Line - INPUT
ABC=56
echo "ABC$ABC ABC"
Command Line - RESPONSE
ABC56 ABC

‘ ’ single quotation

with the ' ' quotation, variables are not converted to assigned strings. $ is considered as a part of the strings.

Command Line - INPUT
ABC=56
echo 'ABC$ABC ABC'
Command Line - RESPONSE
ABC$ABC ABC

The echo command is used for displaying a line of text/string that is included in the argument.

echo with string

When an argument is a string, the echo command returns the string itself.

Command Line - INPUT
echo ABC
Command Line - RESPONSE
ABC

echo with variable

When an argument is a variable, use $ before the variable. the echo command returns an assigned string to the variable.

Command Line - INPUT
ABC=56
echo $ABC
Command Line - RESPONSE
56

echo with string and variable

You can connect strings and variables in the echo command.

Command Line - INPUT
ABC=56
echo ABC$ABC
Command Line - RESPONSE
ABC56

" " double quotation and ' ' single quotation

You can connect strings or variables with special characters or spaces with the " " or ' ' quotation; however, there is a slight difference.

" " double quotation

with the " " quotation, variables are converted to assigned strings.

Command Line - INPUT
ABC=56
echo "ABC$ABC ABC"
Command Line - RESPONSE
ABC56 ABC

‘ ’ single quotation

with the ' ' quotation, variables are not converted to assigned strings. $ is considered as a part of the strings.

Command Line - INPUT
ABC=56
echo 'ABC$ABC ABC'
Command Line - RESPONSE
ABC$ABC ABC
Tag: