Both of these commands work: (note the -S
in sudo
tells sudo to read the password from stdin).
echo 'mypassword' | sudo -S tee -a /etc/test.txt &> /dev/null
echo -e 'nsomenmorentext' | sudo tee -a /etc/test.txt &> /dev/null
Now I would like to combine the two, i.e. achieve everything in just one line. But, of course, something like this doesn’t work:
echo -e 'nsomenmorentext' | echo 'mypassword' | sudo -S tee -a /etc/test.txt &> /dev/null
What would work? Thanks:) – Loady
PS: Minor unrelated question: is 1> identical to > ? I believe they are..