Append to protected file
bash, macos, shell, unix
Solution
echo "Append string" | sudo tee -a protected_file >/dev/null
Problem
I want to do something along the lines of: ``` echo "Append string" >> protected_file ``` However, as this file is write protected I get an error. Running: ``` sudo echo "Append string" >> protected_file ``` seems to run sudo on the echo command, and still gives me the permission error, how do I append to this file?