按列优先级排序CSV文件,使用“sort”命令 [英] Sort CSV file by column priority using the "sort" command

查看:220
本文介绍了按列优先级排序CSV文件,使用“sort”命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,我想按列优先级,如order by排序。例如:

I have a csv file, and I would like to sort it by column priority, like "order by". For example:

3;1;2
1;3;2
1;2;3
2;3;1
2;1;3
3;2;1


b $ b

如果这种情况是select的结果,order by将如下:order by column2,column1,column3 - 结果将是:

If this situation was the result of a "select", the "order by" would be as follows: order by column2, column1, column3 - the result would be:

2;1;3
3;1;2
1;2;3
3;2;1
1;3;2
2;3;1

如何在Unix上使用sort命令获得相同的结果。

I'd like to know how to get this same result using "sort" command on Unix.

推荐答案

sort --field-separator=';' --key=2,1,3

这篇关于按列优先级排序CSV文件,使用“sort”命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆