Skip to content

gbenson.net

Category: bash

sudo tee >/dev/null

Need to redirect to a file from sudo? Use sudo tee >/dev/null:

$ sudo ls -l /root >/root/files.list
-bash: /root/files.list: Permission denied
$ sudo ls -l /root | sudo tee /root/files.list >/dev/null
$ sudo ls -l /root/files.list
-rw-r--r-- 1 root root 94 Oct 18 09:31 /root/files.list
gbenson bash, shell, Snippets Wednesday 18th October 2023Friday 1st December 2023 1 Minute

sed trick

I discovered a new sed trick today:

sed -i~

“I” stands for “in place”. It edits the files in place! And makes a backup if you want!

gbenson bash, sed, shell, Snippets 1 Comment Wednesday 22nd April 2020Wednesday 22nd April 2020 1 Minute
Proudly powered by WordPress | Theme: Independent Publisher 2 by Raam Dev.