如何使用awk过滤列?
这就是专栏:
$ awk -F'|' 'NR==1{print $7} NR>1{print $7;}' head_datafile_pipe_deleimiter.csv
"Product_Description"
"PREPAY PLUS - $0 -"
"$39.95 Plan"
"$69.95 Plan"
"$29.95 Carryover Plan 1GB"
"PREPAY PLUS - $0 -"
"$19 CO COMBO - NOT RECURRENT"
"$39.95 Plan"
"PREPAY PLUS - $1 - #33"
"PREPAY PLUS - $0 -"
现在我只想用这个"PREPAY PLUS - $0 -"
来显示行,但是我似乎没有工作。 如何使其有效?
$ awk -F'|' 'NR==1{print $7} NR>1{if($7=="PREPAY PLUS - $0 -") print $7;}' head_datafile_pipe_deleimiter.csv
"Product_Description"
答案 0 :(得分:1)
$ awk -F'|' -v dq='"' 'NR==1{print $7} NR>1{if($1==dq"PREPAY PLUS - $0 -"dq) print $7;}' test.in
"Product_Description"
"PREPAY PLUS - $0 -"
"PREPAY PLUS - $0 -"
"PREPAY PLUS - $0 -"