echo (Echo input)
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.
echo ABC
ABC
echo with variable
When an argument is a variable, use $
before the variable. the echo
command returns an assigned string to the variable.
ABC=56
echo $ABC
56
echo with string and variable
You can connect strings and variables in the echo
command.
ABC=56
echo ABC$ABC
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.
ABC=56
echo "ABC$ABC ABC"
ABC56 ABC
‘ ’ single quotation
with the '
'
quotation, variables are not converted to assigned strings. $
is considered as a part of the strings.
ABC=56
echo 'ABC$ABC ABC'
ABC$ABC ABC