• awk 打印从某一列到最后一列的内容


    数据内容来源于  linux history的命令输出

    awk命令

    1
    history|awk -F " " '{for (i=2;i<=NF;i++)printf("%s ", $i);print ""}'

    详解:

    history:linux命令

    awk -F “ ”  以空格为分隔符

    for (i=2;i<=NF;i++) printf("%s ",$i)  从第二列开始到最后,注意%s 后面有空格。

    print “” 打印组合

    示例:

    cat test.txt |awk -F ":" '{for(i=6;i<=NF;i++)printf("%s ",$i);print ""}' {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 3,"store" 4,"productId" 466227,"spu" "NHGA508873","image" "product/2021/12/4/1466955091331387392.jpg","salesTimes" 4,"salesUsers" 4,"salesQty" 8,"salesTotal" 32.076,"orderTimes" 4,"orderUsers" 4,"orderQty" 8,"orderTotal" 32.076,"buyOnceUsers" 0,"buyTwiceUsers" 0,"buyThreeUsers" 1,"buyFourUsers" 0,"buyFiveUsers" 0,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1638759536534,"device toreGroupKey" 30004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 3,"store" 4,"productId" 466228,"spu" "NHGA508874","image" "product/2021/12/4/1466955131953221632.jpg","salesTimes" 4,"salesUsers" 4,"salesQty" 7,"salesTotal" 28.026,"orderTimes" 4,"orderUsers" 4,"orderQty" 7,"orderTota " 28.026,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1638759536534,"deviceStoreGroupKey" 30004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 4,"store" 4,"productId" 466222,"spu" "NHRU508522","image" "product/2021/12/4/1466942443919380480.jpg","salesTimes" 1,"salesUsers" 1,"salesQty" 1,"salesTotal" 4.36,"orderTimes" 1,"orderUsers" 1,"orderQty" 1,"orderTotal" 4.36,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1638759536950,"deviceStoreGroupKey" 40004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 4,"store" 4,"productId" 466223,"spu" "NHJZ508559","image" "product/2021/12/4/1466943907668561920.jpg","orderTimes" 1,"orderUsers" 1,"orderQty" 2,"orderTotal" 17.82,"categoryIdLv1" 1258,"categoryIdLv2" 1306,"createdAt" 638759536950,"deviceStoreGroupKey" 40004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 4,"store" 4,"productId" 466226,"spu" "NHGA508871","image" "product/2021/12/4/1466955010549092352.jpg","orderTimes" 1,"orderUsers" 1,"orderQty" 1,"orderTotal" 3.38,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1 38759536950,"deviceStoreGroupKey" 40004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 4,"store" 4,"productId" 466227,"spu" "NHGA508873","image" "product/2021/12/4/1466955091331387392.jpg","salesTimes" 4,"salesUsers" 4,"salesQty" 8,"salesTotal" 32.076,"orderTimes" 4,"orderUsers" 4,"orderQty" 8,"orderTota " 32.076,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1638759536950,"deviceStoreGroupKey" 40004000}} {"_class" "com.nhjewelry.model.elasticsearch.model.CrmProductStatistics","statisticsTime" 1638662400000,"platform" 2,"device" 4,"store" 4,"productId" 466228,"spu" "NHGA508874","image" "product/2021/12/4/1466955131953221632.jpg","salesTimes" 4,"salesUsers" 4,"salesQty" 7,"salesTotal" 28.026,"orderTimes" 4,"orderUsers" 4,"orderQty" 7,"orderTota " 28.026,"categoryIdLv1" 1258,"categoryIdLv2" 1259,"createdAt" 1638759536950,"deviceStoreGroupKey" 40004000}}

      

  • 相关阅读:
    8-6.布局元素实战
    Unity3D NGUI插件(3.12/2018/2019)
    GoLang 数据结构-二叉树
    GoLang 数据结构-哈希表(散列表)
    GoLang 四大经典排序(冒泡排序,选择排序,插入排序,快速排序)写法及执行效率
    GoLang 数据结构-单向链表,双向链表,单向环形链表
    GoLang 数据结构-环形队列
    GoLang 数据结构-稀疏数组
    GoLang 海量用户聊天系统(TCP-Socket网络编程+Redis数据库+协程)
    GoLang 使用协程和管道获取随机数
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/15684052.html
Copyright © 2020-2023  润新知