I want to write a full shell script using
>> to append commands to a file. For example, consider the following script as if it was created with an editor.
echo Hello World, done echo please enter the first number read num1 echo please enter the second number read num2 echo $num1 plus $num2 is `expr $num1 + $num2`
In a terminal window, I have tried typing
echo echo Hello World, "done" >> file.sh to write all the lines to a file.
I put quotation marks around "done" to make sure that when I run the file, the terminal doesn't consider the keyword "done". However, when I check the file to see if I have done it correctly, the keyword "done" doesn't have the quotation marks. Also the last line in the code above, when typed into a terminal window and appended into the file, all the file displays is
echo plus is. I am wondering why the variables and the
expr expression don't append to the file. I basically want to recreate the code above from a terminal window. I am running Ubuntu 12.04 with bash version 4.2.24