命令行 – 使用AWK重新排序列
发布时间:2020-12-14 02:09:46 所属栏目:Linux 来源:网络整理
导读:我需要重新排序此(制表符分隔)数据的列: 1 cat plays 1 dog eats 1 horse runs 1 red dog 1 the cat 1 the cat 所以这是打印像: cat plays 1dog eats 1horse runs 1red dog 1the cat 2 我试过了: sort [input] | uniq -c | awk '{print $2 "t" $3 "t" $
我需要重新排序此(制表符分隔)数据的列:
1 cat plays 1 dog eats 1 horse runs 1 red dog 1 the cat 1 the cat 所以这是打印像: cat plays 1 dog eats 1 horse runs 1 red dog 1 the cat 2 我试过了: sort [input] | uniq -c | awk '{print $2 "t" $3 "t" $1}' > [output] 结果是: 1 cat 1 1 dog 1 1 horse 1 1 red 1 2 the 1 谁能给我一些关于出了什么问题的见解? 解决方法
由于cat输入输出|排序| uniq -c是:
1 1 cat plays 1 1 dog eats 1 1 horse runs 1 1 red dog 2 1 the cat 你需要这样的东西: cat input | sort | uniq -c | awk '{print $3 "t" $4 "t" $1}' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |