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

16 lines
642 B
Plaintext

# Display `ls` output to the user, but also write it to the given file.
ls | tee outfile.txt
# As above, but amend the data; previous file's data remains in-tact.
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 %