I want to insert text at the top of an already existing file. How can I achieve this. I tried echo
and tee
but was not successful.
I was trying to insert repo line at the top of sources.list
file from terminal.
Note
I need an one line quick solution, because another answer's method was known to me already
echo "deb http://extras.ubuntu.com/ubuntu precise main" | sudo tee -a /etc/apt/sources.list
-- you also need sudo before tee to get admin privileges. But why on earth would you want to add something on the very top of sources.list?