2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-03 15:40:17 +00:00
cheat.sheets/sheets/tee

18 lines
692 B
Plaintext
Raw Normal View History

# 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
# 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
# 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
# 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
# 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 %