sort怎样按指定的列排序
0000 27189 41925425
065f 15 41925425
0663 7 41925425
0675 5 41925425
0691 76 41925425
0693 2 41925425
06a7 82 41925425
06a9 58 41925425
06bf 68 41925425
06c1 56 41925425
06d7 145 41925425
06e1 127 41925425
06e3 230 41925425
06e5 7 41925425
06ef 48 41925425
06f1 463 41925425
06ff 3847 41925425
070b 2376 41925425
070d 3408 41925425
0713 109025 41925425
0715 4 41925425
0726 134 41925425
我想按第二列值进行排序,从大到小的顺序。
看了下man,还是不大明确,还请大家指点一二。

答案:sort -n -k2 file.txt 或则sort -g -k2 file.txt(从小到大排序)
-n, --numeric-sort
-g, --general-numeric-sort
sort -rn -k2 all_contig.txt (加-r从大到小排序)

使用方法:sort [选项]... [文件]...
Write sorted concatenation of all FILE(s) to standard output.

长选项必须用的參数在使用短选项时也是必须的。
顺序选项:

-b, --ignore-leading-blanks ignore leading blanks
-d, --dictionary-order consider only blanks and alphanumeric characters
-f, --ignore-case fold lower case to upper case characters
-g, --general-numeric-sort compare according to general numerical value
-i, --ignore-nonprinting consider only printable characters
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'
-n, --numeric-sort compare according to string numerical value
-r, --reverse reverse the result of comparisons

Other options:

-c, --check check whether input is sorted; do not sort
-k, --key=POS1[,POS2] start a key at POS1, end it at POS2 (origin 1)
-m, --merge merge already sorted files; do not sort
-o, --output=FILE write result to FILE instead of standard output
-s, --stable stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE use SIZE for main memory buffer
-t, --field-separator=SEP use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
-u, --unique with -c, check for strict ordering;
without -c, output only the first of an equal run
-z, --zero-terminated end lines with 0 byte, not newline
--help 显示此帮助信息并退出
--version 输出版本号信息并退出

POS is F[.C][OPTS], where F is the field number and C the character position
in the field. OPTS is one or more single-letter ordering options, which
override global ordering options for that key. If no key is given, use the
entire line as the key.

SIZE may be followed by the following multiplicative suffixes:
% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.

With no FILE, or when FILE is -, read standard input.

*** WARNING ***
The locale specified by the environment affects sort order.
Set LC_ALL=C to get the traditional sort order that uses
native byte values.

请向 <bug-coreutils@gnu.org> 报告错误。

linux sort按照指定列排序的更多相关文章

  1. [转帖]linux Shell sort按照指定列排序

    linux Shell sort按照指定列排序 https://blog.csdn.net/weixin_38308151/article/details/80760133 kubectl get p ...

  2. QRowTable表格控件-支持hover整行、checked整行、指定列排序等

    目录 一.开心一刻 二.嘴一嘴 三.效果展示 四.浅谈实现 五.自定义数据源 1.data函数 2.flags函数 六.自定义视图 1.目的 2.问题分析 七.测试 八.相关文章 原文链接:QRowT ...

  3. PHP 距离我最近排序+二维数组按指定列排序

    思路: 1.获取我的位置,即:我的经纬度 2.各站点须有位置     即:排序对象有位置经纬度 3.查询要排序的站点列表 4.循环遍历计算  与我的距离 5.二维数组按 指定列(距离)排序 具体如下: ...

  4. linux 中sort命令 按照指定列排序

    sort怎样按指定的列排序0000 27189 41925425065f 15 419254250663 7 419254250675 5 419254250691 76 419254250693 2 ...

  5. Linux sort 多字段分组排序

    常用参数: -t: 指定分隔符 -k: 指定域 -u: 去除重复行 -n: 以数值排序 -r: 降序排序 (sort默认的排序方式是升序) -o: 结果重定向输出到文件 1.源文件: # cat hh ...

  6. Linux sort -n 与 -g 排序对比

    公司业务需要,天天用awk统计数值然后排序,出问题了,如下: count.sh 是一个统计脚本,把awk输出的值按占比.条数.类型 在重新输出 awk -F\| '{print $16}' *MQTT ...

  7. C# DataTable按指定列排序

    C#提供的内置对象DataTable功能特别的强大,如果我们需要对DataTable中的某一列进行排序怎么处理呢,具体代码如下: DataTable dt = new DataTable(); dt. ...

  8. oracle按照指定列排序操作

    按照...分组排序后,得到行编号: row_number() over(partition by ... order by ...) 按照...分组排序后,得到相应的列的第一个数据: first_va ...

  9. 轻松Angularjs实现表格按指定列排序

    angular表格点击序号进行升序,再次点击进行降序排序,在输入框输入信息,出现相对应数据的那一行. html: <input type="text" ng-model=&q ...

随机推荐

  1. quick-cocos2d-x transition使用方法

    Functions transition.newEasing(action, easingName, more) 为图像创造效果 transition.execute(target, action,  ...

  2. TCP/IP详解 卷一(第十一章 UDP:用户数据报协议)

    UDP是一个简单的面向数据报的运输层协议. UDP不提供可靠性:它把应用程序传给IP层的数据发送出去,但是并不保证它们能到达目的地. UDP首部的个字段如下图所示

  3. js中的string.format函数代码

    String.prototype.format = function(args) { if (arguments.length > 0) { var result = this; if (arg ...

  4. 关系型数据的分布式处理系统MyCAT(转载)

      ——概述和基本使用教程 日期:2014/12/24 文:阿蜜果 1.   MyCAT概述 1.1 背景 随着传统的数据库技术日趋成熟.计算机网络技术的飞速发展和应用范围的扩充,数据库应用已经普遍建 ...

  5. [译] ContentEditable 那些好的、坏的和坑

    译者注 我的上一篇译文 “[译] 通过 contentEditable 属性创建一个所见即所得的编辑器” 的原文 “Create a WYSIWYG Editor With the contentEd ...

  6. CAN协议学习(一)协议介绍

    一.简介 CAN 是 Controller Area Network 的缩写(以下称为 CAN),是 ISO 国际标准化的串行通信协议. 在当前的汽车产业中,出于对安全性.舒适性.方便性.低公害.低成 ...

  7. Android studio 百度地图开发(3)地图导航

    Android studio 百度地图开发(3)地图导航 email:chentravelling@163.com 开发环境:win7 64位,Android Studio,请注意是Android S ...

  8. hdu2767之强联通缩点

    Proving Equivalences Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  9. maven 依赖文件 pom.xml 编译 mvn compile 运行 不用mvn exec:java -Dexec.mainClass="hello.HelloWorld" 打成jar包 mvn package mvn install http://blog.csdn.net/yaya1943/article/details/48464371

    使用maven编译Java项目 http://blog.csdn.net/yaya1943/article/details/48464371  使用"mvn clean"命令清除编 ...

  10. ActiveMQ与xml rpc

    最近项目在做平台间的消息传递,也让我对平台间消息的传递进行了深一步的探讨.先叙述一下概况 公司上一个版本用的是winform做的监控软件,主要做设备的通信和控制,基本的连接如下