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. ACM-百度之星资格赛之Labyrinth——hdu4826

    Labyrinth Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. hdu5399

    题意:给你m行个长度为 n的序列或者-1 -1代表这一行的序列不确定,然后让你找出有多少种情况满足对于每一个i 有f1(f2(⋯fm(i)))=i: 思路:分为三种情况:1,每行序列中有反复数输出0: ...

  3. Atitit.go语言golang语言的新的特性  attilax总结

    Atitit.go语言golang语言的新的特性  attilax总结 1. 继承树less  动态接口1 1.1. 按照书中说的,Go语言具有以下的特征,下面我们分别来进行介绍.  q 自动垃圾回收 ...

  4. kafka eagle 使用教程

    下载 地址:http://download.smartloli.org/ github:https://github.com/smartloli/kafka-eagle 环境 Windows: 安装J ...

  5. 调整jvm内存

    1.使用解压tomcat     在catalina.bat的第一行增加:    set JAVA_OPTS=-Xms64m -Xmx256m -XX:PermSize=128M -XX:MaxNew ...

  6. Linux中终端和控制台区别

    Linux中终端和控制台区别: 终端:英文名叫terminal 控制台:英文名叫console 两者区别要从以前的多人使用的计算机开始 以前,由于计算机很昂贵,所用一台计算机一般由多个人同时使用.这样 ...

  7. Dockerfile安装KOD可道云

    [root@docker01 base2]# cat Dockerfile FROM centos:6.8 RUN yum install openssh-server -y RUN /etc/ini ...

  8. 【JMeter4.0学习(八)】之断言

    目录 响应断言 一.响应断言 1.添加线程组 2.添加HTTP请求默认值 3.添加HTTP请求1 4.先运行“HTTP请求1”,查看结果树的“取样器结果.请求.响应数据” ①取样器结果 ②请求 ③响应 ...

  9. wamp 两个不同的php.ini

    最近在本地开发的windows wamp环境安装一个vld 扩展,碰见一个奇怪的问题,phpinfo() 有 而cli 命令模式里面却没有 最后发现wamp phpinfo()和cli命令模式指向的p ...

  10. RabbitMQ集群安装配置+HAproxy+Keepalived高可用

    RabbitMQ集群安装配置+HAproxy+Keepalived高可用 转自:https://www.linuxidc.com/Linux/2016-10/136492.htm rabbitmq 集 ...