zoukankan      html  css  js  c++  java
  • tee & vim

    tee [OPTION]... [FILE]...
    
         +-----------+    tee     +------------+
         |           |  --------  |            |
         | ps -ax    |  --------  | grep 'foo' |
         |           |     ||     |            |
         +-----------+     ||     +------------+
                           ||   
                   +---------------+
                   |               |
                   | processes.txt |
                   |               |
                   +---------------+
    

    Options

    -a, --append 	Append to the given FILEs. Do not overwrite.
    -i, --ignore-interrupts 	Ignore interrupt signals.
    --help 	Display a help message, and exit.
    --version 	Display version information, and exit.
    

    输出到stdout同时,覆盖写入文件

    df -h | tee disk_usage.txt
    

    只写入文件,不输出到stdout

    command | tee file.out >/dev/null
    

    sudo 模式将信息追加到指定文件,同时stdout显示

    echo "newline" | sudo tee -a /etc/file.conf
    

    重定向同时,写入文件

    grep 'root' /etc/passwd | tee /tmp/passwd.tmp | wc -l
    

    同时覆盖写入多个文件

    command | tee file1.out file2.out file3.out
    

    追加模式写入

    command | tee -a file.out
    

    写入内容忽略中断信号ctrl+c

    command | tee -i file.out
    

    vim sudo写入

    :w !sudo tee %
    

    You can add this to your .vimrc to make this trick easy-to-use: just type :w!!.

    " Allow saving of files as sudo when I forgot to start vim using sudo.

    cmap w!! w !sudo tee > /dev/null %
    

    The > /dev/null part explicitly throws away the standard output, since, as I said, we don't need to pass anything to another piped command.

  • 相关阅读:
    axios核心技术---1.HTTP相关
    Leetcode刷题
    Java入门13---Optional处理null对象
    Java入门12---Stream
    谈谈前后端分离及认证选择
    react监控props的变化
    如何使用懒加载
    CSS文字超出省略
    React的slot插槽
    React 的函数组件和类组件中的props
  • 原文地址:https://www.cnblogs.com/Searchor/p/13882779.html
Copyright © 2011-2022 走看看