I wanted to add to my hosts file easily using a one line command, but I get an unexpected result.
$ sudo sh -c 'echo -e "10.0.10.0\tserver.bananas.com\tserver" >> /etc/hosts'
$ cat /etc/hosts
-e 10.0.10.0 server.bananas.com server
I'm using the -e switch on echo to enable the use of backslash escapes for the tabs, but the -e is being included in the redirected output.
How can I avoid this?
sh
is likely a shell (such asdash
) whoseecho
built-in doesn't have a-e
switch – steeldriver Dec 19 '18 at 03:42