This is a follow-up question to
If you want to redo the same command with sudo !!
after doing a command like this:
echo "something">/path/file
You can use the global replace syntax to recall the command:
!!:gs/>/|sudo tee -a /
Use a space after the -a parameter.
This is the equivalent to sudo !! but helps you bypass sudo restrictions for the < and >. Because sudo does not allow you to use [<, >].
How can I put this into an alias on my .bashrc
so I can use it simple?
I tried
alias redo='!!:gs/>/|sudo tee -a /'
But this doesn't work, I get the error:
$ echo "sdfdsf">/path/file
bash: /path/file: no permissions
$ redo
bash: /: Is a directory
tee: /: Is a directory