![根据第一列内容中的重复项对文件中的重复项进行排序](https://linux22.com/image/1171826/%E6%A0%B9%E6%8D%AE%E7%AC%AC%E4%B8%80%E5%88%97%E5%86%85%E5%AE%B9%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E9%A1%B9%E5%AF%B9%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E9%87%8D%E5%A4%8D%E9%A1%B9%E8%BF%9B%E8%A1%8C%E6%8E%92%E5%BA%8F.png)
答案1
我假设您只想获取一条重复的记录,而不需要其余没有重复的记录:
awk -F, 'a[$1]++{print $1}' my_file
例子:
$ cat shasums
804951ce256f190e77baba24f29b6b1890b3e9df ./bell.wav
793e3a485bd29d1e5a87493fa566624d4742f215 ./output.sh
b35bd58dd07d7e3375dea1aee4c5e73e470a928b ./package-lock.json
804951ce256f190e77baba24f29b6b1890b3e9df ./bell.wav
b35bd58dd07d7e3375dea1aee4c5e73e470a928b ./package-lock.json
b35bd58dd07d7e3375dea1aee4c5e73e470a928b ./package-lock.json1
d1847e16de5717f9a35eab98f974c20a867019eb ./shasums
$ awk -F, 'a[$1]++{print $1}' shasums
804951ce256f190e77baba24f29b6b1890b3e9df ./bell.wav
b35bd58dd07d7e3375dea1aee4c5e73e470a928b ./package-lock.json