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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM