我有一个包含五列的文件,第二列包含分隔符文本。我想要将该分隔符文本拆分、去重并打印成行。我已经使用以下命令完成了这个操作。现在我想写一个awk脚本,有人能帮我吗。
awk -F"\t" 'NR>1{print $2}' <input file> | awk -F\| '{for (i = 0; ++i <= NF;) print $i}' | awk '!x[$0]++'
输入文件:
test hello|good|this|will|be 23421 test 4543
test2 good|would|may|can 43234 test2 3421
输出:
hello
good
this
will
be
would
may
can
awk '{print $2}' inputfile|sed 's/|/\n/gp'|sort|uniq
awk '{print $2}' inputfile | sed 's/|/\n/gp' | sort | uniq
- roblogic