2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-11 01:10:31 +00:00
cheat.sheets/sheets/tee
Alex Berry 15f7213025 Append, not amend.
intact is not hyphenated.

Newline for formatting.
2020-02-11 23:08:07 +00:00

18 lines
692 B
Plaintext

# Display `ls` output to the user, but also write it to the given file.
ls | tee outfile.txt
# As above, but append the data; previous file's data remains intact while
# new data is added at the end of the file.
ls | tee -a outfile.txt
# 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
# Workaround to output data to a file, with root privileges.
echo 3 | sudo tee /proc/sys/vm/drop_caches
# 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.
:w !sudo tee %