echo "variable1 variable2"

S67567

New Member
Credits
28
hello, I'd like to know how to echo 2 variable in one string, like that :
echo "<variable1> <variable2>" > my_file
TIA !
 


JasKinasis

Well-Known Member
Credits
3,079
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:


Members online


Top