Sco*_*vis 2 awk command-prompt
我正在寻找一种在命令提示符环境中使用 AWK 打印字段中不同值的方法。
ID Title Promotion_ID Flag
12 Purse 7 Y
24 Wallet 7 Y
709 iPhone 1117 Y
74 Satchel 7 Y
283 Xbox 84 N
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想返回 Promotion_ids: 7, 1117, 84。我在 Google 上研究了这个问题,并找到了一些示例,例如:
`cut -f 3 | uniq *filename.ext*` (returned error)
`awk cut -f 3| uniq *filename.ext*` (returned error)
`awk cut -d, -f3 *filename.ext* |sort| uniq` (returned error)
Run Code Online (Sandbox Code Playgroud)
awk 'NR>1{a[$3]++} END{for(b in a) print b}' file
Run Code Online (Sandbox Code Playgroud)
输出:
7 84 1117