转自:https://www.runoob.com/linux/linux-comm-awk.html
1.awk命令
AWK 是一种处理文本文件的语言,是一个强大的文本分析工具。
# log.txt
2 this is a test 3 Do you like awk This's a test 10 There are orange,apple,mongo
awk '{[pattern] action}' {filenames} # 行匹配语句 awk '' 只能用单引号
检索:
# 每行按空格或TAB分割,输出文本中的1、4项 $ awk '{print $1,$4}' log.txt --------------------------------------------- 2 a 3 like This's 10 orange,apple,mongo # 格式化输出 $ awk '{printf "%-8s %-10s\n",$1,$4}' log.txt --------------------------------------------- 2 a 3 like This's 10 orange,apple,mongo
看起来功能有点像python中的pandas包?
标签:10,apple,like,学习,命令,awk,txt,log From: https://www.cnblogs.com/BlueBlueSea/p/16739506.html