【发布时间】:2012-02-17 13:25:28
【问题描述】:
我有一个 4 列的 CSV 文件。我想对这些行进行排序,以便将第三列中某处包含任何数字的行推到文档的末尾,将第三列中没有数字的行放在开头。如何以这种方式对文件进行排序?
更新:
为了澄清,我需要在第三列的字母中移动包含任何数字(即匹配[0-9])的行(该行的第三列可能包含其他符号)。空格并不重要。例如
dog, eats chicken, has 4 legs, does not like cats
cat, eats mice, has a tail, does not like water
mouse, eats bugs, has 4 legs, does not like cats
elephant, eats peanuts, has a trunk, does not like mice
将被排序到:
cat, eats mice, has a tail, does not like water
elephant, eats peanuts, has a trunk, does not like mice
dog, eats chicken, has 4 legs, does not like cats
mouse, eats bugs, has 4 legs, does not like cats
【问题讨论】:
标签: bash shell sorting csv awk