S S67567 New Member Joined May 31, 2020 Messages 3 Reaction score 1 Credits 28 Jun 8, 2020 #1 hello, I'd like to know how to echo 2 variable in one string, like that : echo "<variable1> <variable2>" > my_file TIA !
hello, I'd like to know how to echo 2 variable in one string, like that : echo "<variable1> <variable2>" > my_file TIA !
JasKinasis Super Moderator Staff member Gold Supporter Joined Apr 25, 2017 Messages 1,861 Reaction score 2,721 Credits 16,092 Jun 8, 2020 #2 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: Jun 8, 2020
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.
OP S S67567 New Member Joined May 31, 2020 Messages 3 Reaction score 1 Credits 28 Jun 9, 2020 #3 Thank you !