使用Unix排序对多个键进行排序 [英] Sorting multiple keys with Unix sort

查看:57
本文介绍了使用Unix排序对多个键进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些潜在的大文件,需要按1-n键排序.其中一些键可能是数字键,有些则可能不是数字键.这是一个固定宽度的柱状文件,因此没有定界符.

I have potentially large files that need to be sorted by 1-n keys. Some of these keys might be numeric and some of them might not be. This is a fixed-width columnar file so there are no delimiters.

使用Unix排序是否有一个很好的方法?使用一个键,就像使用"-n"一样简单.我已经阅读了手册页并简短地搜索了Google,但没有找到一个很好的例子.我将如何实现这一目标?

Is there a good way to do this with Unix sort? With one key it is as simple as using '-n'. I have read the man page and searched Google briefly, but didn't find a good example. How would I go about accomplishing this?

注意:由于文件大小的可能,我已经排除了Perl.这将是最后的选择.

Note: I have ruled out Perl because of the file size potential. It would be a last resort.

推荐答案

使用-k选项(或--key=POS1[,POS2]).它可以出现多次,并且每个键都可以具有全局选项(例如n用于数字排序)

Use the -k option (or --key=POS1[,POS2]). It can appear multiple times and each key can have global options (such as n for numeric sort)

这篇关于使用Unix排序对多个键进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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