LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 892|回复: 2

问一个sort命令

[复制链接]
发表于 2006-1-22 16:39:29 | 显示全部楼层 |阅读模式
sort -k 1,1 -k 2n
这句话里的2n是什么意思阿?
发表于 2006-1-22 23:14:36 | 显示全部楼层
[HTML]Note that if you had written `-k 2n' instead of `-k 2,2n' `sort'
would have used all characters beginning in the second field and
extending to the end of the line as the primary _numeric_ key. For
the large majority of applications, treating keys spanning
more than one field as numeric will not do what you expect.

Also note that the `n' modifier was applied to the field-end
specifier for the first key.  It would have been equivalent to
specify `-k 2n,2' or `-k 2n,2n'.  All modifiers except `b' apply
to the associated _field_, regardless of whether the modifier
character is attached to the field-start and/or the field-end part
of the key specifier.
[/HTML]
2的意思好理解,n 即是 -n
回复 支持 反对

使用道具 举报

发表于 2006-2-6 09:54:00 | 显示全部楼层
加n表示按数字大小排序,比如123, 23, 12,
# sort -k1
12
123
23

# sort -k1n
12
23
123
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表