Redirecting stdout to a file you don't have write permission on
I'm new i'm trying to learn shell scripting.
Is there a way to force a concatenation and override the privileges doing the following one line command?
read domain; echo "127.0.1.1 $domain " >> /etc/hosts
What i'm trying to do is just create a simple script to type in the domain and then add it to my hosts file for development. Since my hosts file has restrictive permissions (even though i'm the only user with sudo powers) it won't let go.
The ideal output would just do the following: