sudo & redirect output
Let's say I want to add some line into /etc/profile. I try:
$ sudo echo "something" >> /etc/profile bash: /etc/profile: Access forbidden
Of course I could write:
$ sudo su # echo "something" >> /etc/profile
and this works, however it does not work within a shell script.
So, what is the right way?