简体   繁体   English

如何使用和排序uniq命令从第一个字符中删除n个字符,然后从中删除n个字符

[英]how to use and sort uniq command to remove n characters from first and n characters after

I am having file containing following lines 我有包含以下行的文件

abcd15051969vignesh
efgh16071989ganesh
ijkl18091972murugesh
mnop15051969santhosh
qrst21061967mahesh
uvwx16071989suresh

now I want to sort the lines on the basis of date of birth and remove the duplicate lines containing same date of birth 现在我要根据出生日期对行进行排序,并删除包含相同出生日期的重复行

You can tell sort to sort by date and to return unique values: 您可以告诉sort按日期排序并返回唯一值:

sort -u -k1.9,1.12 -k1.7,1.8 -k1.5,1.6 < input
      ^             ^
      |             |
    unique       start the sort
                 key at 1st word,
                 from char 7 to 8

Output 输出量

qrst21061967mahesh
abcd15051969vignesh
ijkl18091972murugesh
efgh16071989ganesh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM