Right now I execute the following command in bash:
sudo tee /proc/acpi/nvhda <<<ON
However, I would like to use that command in fish instead of bash. The <<< does not work in fish an throws an error. What would be the equivalent in fish?
I tried to pipe an echo, but that throws me a permission denied.
sudo echo "ON" | /proc/acpi/nvhda
As an approach that works in fish just as effectively as it works in POSIX-family shells:
echo ON | sudo tee /proc/acpi/nvhda
There's no point to sudo echo
-- echo
just writes to the already-open stdout handle it inherited from its parent process; it doesn't open any files, so it doesn't need any permissions.
The point to tee
is having a process external from the shell that can thus be on the other end of sudo
. That works whether or not you have heredoc or herestring support in use.