例如,
Name Local International Total
Monash University 42339 22140 64479
RMIT University 30843 26590 57433
University of Sydney 42028 12278 54306
University of New South Wales 39194 13132 52326
University of Melbourne 38091 14166 52257
University of Queensland 37252 11519 48771
我试试cat filename|sort -k 3 -n
标题将最终在中间,但我想按国际数量对其进行排序,并将标题保持在顶部。如何修复我的管道?
答案 0 :(得分:1)
您可以使用文字选项卡作为排序中的分隔符(使用bash和ksh语法)
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
</body>
</html>
便携地:
$ <input.txt sed 1q ; \
<input.txt sed 1d | sort -t$'\t' -k 3,3 -n
您还可以将空格转换为某些您未使用的字符,如$ <input.txt sed 1q ; \
<input.txt sed 1d | sort -t"$(printf '\t')" -k 3,3 -n
,对行进行排序,然后在完成后将其转换回来。
%