我正在运行以下命令来处理一些CSV数据
grep -i "area harvested.*2005" ps1_apricot_countries_2005.csv | sed 's/\"//g'
结果如下(前7项记录仅作为示例显示):
Afghanistan,31,Area Harvested,2005,Ha,5200.00000,F
Africa +,31,Area Harvested,2005,Ha,59536.00000,A
Albania,31,Area Harvested,2005,Ha,400.00000,F
Algeria,31,Area Harvested,2005,Ha,22888.00000,
Americas +,31,Area Harvested,2005,Ha,11496.00000,A
Argentina,31,Area Harvested,2005,Ha,2200.00000,F
Armenia,31,Area Harvested,2005,Ha,5300.00000,
Asia +,31,Area Harvested,2005,Ha,272644.00000,A
可以看出,这是按字母顺序排列在第一列上的。
我想把这个
sort
以便我可以根据
第6个数字逗号分隔列
.
我尝试了:
grep -i "area harvested.*2005" ps1_apricot_countries_2005.csv | sed 's/\"//g' | sort -k6rn
然而,这导致了以下结果(前7项记录仅作为示例显示):
Afghanistan,31,Area Harvested,2005,Ha,5200.00000,F
Africa +,31,Area Harvested,2005,Ha,59536.00000,A
Albania,31,Area Harvested,2005,Ha,400.00000,F
Algeria,31,Area Harvested,2005,Ha,22888.00000,
Americas +,31,Area Harvested,2005,Ha,11496.00000,A
Argentina,31,Area Harvested,2005,Ha,2200.00000,F
Armenia,31,Area Harvested,2005,Ha,5300.00000,
它似乎仍然按降序排列在第一列,而不是第六列。有人能解释一下如何纠正上述方法来实现这一点吗?