Pretty sure you don't need the shell command part. The double-redirector (">>") says "append to end of file" and you can just echo your output on command.
Just try it yourself
This will create an empty text file called "test.txt"Code:
This single redirect will actually destroy and recreate the file we just created. This is another way to create the file, but with content. Touch can be used on an already existing file to update its time stamp.Code:
echo "I'm the first line" > test.txt
We now made sure there was a carriage return ("Enter") between the first and second line (otherwise we'd append to the same line), and then we terminate our line. It's good to do that. If this was successful (as it was on my PC), then we should see a text file with two lines as we've entered. So check it.Code:
echo "\nI'm the second line\n" >> test.txt
This is no different than doing a print statement in R while we've sinked the output to a file location. Echo is the terminal "print" statement to force things to be printed to the standard output. Just like the sink function, the ">>" redirector changes that standard output to the specified location and being double it sets the parameter to append that output to whatever is there. Make sense?Code:
You could also do something like
and then edit it manually in leafpad (like Windows "notepad." There's also mousepad, gedit, and a bunch of others that are commonly available on Linux systems). The "&" at the end of the line frees up your terminal so it doesn't get stuck running the application until you close the program.Code:
sudo leafpad /etc/apt/sources.list &
Also, you can change in that deb statement the CRAN mirror being used. It's a URL so make sure you visit it to know it is correctly locating your mirror and you didn't mess anything up. The space and "quantal/" is declaring a file on that mirror--viz., the folder that is for your version of ubuntu. So if you're using a different version name, you have to pick the right one (and update it if you upgrade your system). Don't know the name? This is why visiting the URL can help! They're all listed right there. For instance, I'm still on precise apparently.