2020-02-02 19:57:22 +00:00
|
|
|
# Display `ls` output to the user, but also write it to the given file.
|
2017-05-21 19:34:45 +00:00
|
|
|
ls | tee outfile.txt
|
2020-02-11 23:02:53 +00:00
|
|
|
|
|
|
|
# As above, but append the data; previous file's data remains intact while
|
|
|
|
# new data is added at the end of the file.
|
2017-05-21 19:34:45 +00:00
|
|
|
ls | tee -a outfile.txt
|
|
|
|
|
2020-02-02 19:57:22 +00:00
|
|
|
# Pipe the standard output of a given command into `tee`, which then displays
|
|
|
|
# it to the user and sending the data to files `one`, `two`, and `three`.
|
|
|
|
[COMMAND] | tee one two three
|
2017-05-21 19:34:45 +00:00
|
|
|
|
2020-02-02 19:57:22 +00:00
|
|
|
# Workaround to output data to a file, with root privileges.
|
2017-05-21 19:34:45 +00:00
|
|
|
echo 3 | sudo tee /proc/sys/vm/drop_caches
|
|
|
|
|
2020-02-02 19:57:22 +00:00
|
|
|
# Pipe the current Vim buffer to a shell process, which in this case is `tee`.
|
|
|
|
# This is especially useful as a shortcut added to `.vimrc` or similar.
|
2017-05-21 19:34:45 +00:00
|
|
|
:w !sudo tee %
|