echo "variable1 variable2"

S67567

New Member
Joined
May 31, 2020
Messages
3
Reaction score
1
Credits
28
hello, I'd like to know how to echo 2 variable in one string, like that :
echo "<variable1> <variable2>" > my_file
TIA !
 


Use the $ operator to display the value of a variable:
Bash:
echo "$variable1 $variable2" > my_file

Or if you want a < and > around the variables:
Bash:
echo "<$variable1> <$variable2>" > my_file

Note: Both of the above examples will completely rewrite the file my_file each time because we are using > to redirect.

If you want to append the content of the variables to the end of an existing file, you should use >> instead.
 
Last edited:


Top