数据内容来源于 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}}