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}}

  

 

posted @   Oops!#  阅读(3060)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
历史上的今天:
2019-12-13 Kubernetes集群之清除集群
2018-12-13 kubectl top查看k8s pod的cpu , memory使用率情况
2017-12-13 centos6下从源码安装setuptools和pip
点击右上角即可分享
微信分享提示