zoukankan      html  css  js  c++  java
  • shell入门-uniq去重复和tee重定向

    命令:uniq

    选项:-c 显示重复数量

    说明:去重复,不sort多个功能,显示几个重复

    命令:tee

    说明:重定向加上双重输出

    [root@wangshaojun ~]# cat 2.txt
    1
    2
    2
    2
    3
    3
    4
    1
    ac
    5
    [root@wangshaojun ~]# uniq 2.txt   ////消除顺序挨着的重复段

    1
    2
    3
    4
    1
    ac
    5

    ///////////////////////////////////////////////////////////////////

    -c

    [root@wangshaojun ~]# uniq -c 2.txt
    1 1
    3 2
    2 3
    1 4
    1 1
    1 ac
    1 5

    //////////////////////////////////////////////////////////////////////

     先sort排序,然后uniq显示重复数量

    [root@wangshaojun ~]# sort 2.txt |uniq -c
    2 1
    3 2
    2 3
    1 4
    1 5
    1 ac

    //////////////////////////////////////////////////////////////////////////

    tee

    [root@wangshaojun ~]# echo "1111111" > 1.txt
    [root@wangshaojun ~]# cat 1.txt
    1111111
    [root@wangshaojun ~]# echo "1111111" |tee 1.txt  ////输出内容显示在屏幕上
    1111111

    //////////////////////////////////////////////////////////////////////////////

    总结:uniq -c  ////  sort 2.txt | uniq -c   /////    echo “111” |tee 1.txt

  • 相关阅读:
    尾递归
    Appium环境搭建
    虚拟机与主机的相互访问,虚拟机访问外网
    Python
    npm i 安装
    redis过期键删除策略
    Redis的过期策略和内存淘汰机制
    redis的两种持久化方案
    JVM 方法内联
    进程/线程/协程
  • 原文地址:https://www.cnblogs.com/wangshaojun/p/4966752.html
Copyright © 2011-2022 走看看