*nix Tip of the Day: tee

tee is a handy little utility that probably all of you know about, but I just found this year. Consider the following scenario: you're maintaining your Gentoo Linux system and you need to add a line to /etc/portage/package.unmask. So you type

sudo echo "sys-kernel/gentoo-sources" >> /etc/portage/package.unmask

right? Nope! The way shell parsing works, that turns into

(sudo echo "sys-kernel/gentoo-sources") >> /etc/portage/package.unmask

which is most certainly not what you want, since you probably don't have permissions to /etc/portage/package.unmask. The solution is the tee utility. It would be invoked like the following:

echo "sys-kernel/gentoo-sources" | sudo tee -a /etc/portage/package.unmask

Well, this was a short post. Oh well. :-)


Want to comment on this? How about we talk on Mastodon instead? mastodon logo Share on Mastodon