echo (Echo input)
![](/_next/image/?url=https%3A%2F%2Fstatic-staging.d-libro.com%2F01-course-content-images%2F2011-10-Linux-Introduction%2F010-main-figures%2Fecho-echo-input-id201110050810.webp&w=1920&q=75)
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