Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

shell实现找出文本中重复的行

  1. User

    shell实现找出文本中重复的行

  2. Assistant

    可以使用sort和uniq命令搭配使用来找出文本中重复的行:

    1. 对文本进行排序
    sort filename.txt
    
    1. 找出重复的行
    sort filename.txt | uniq -d
    

    其中,-d参数表示只显示重复的行。如果想要同时显示重复的行和出现的次数,可以使用-c参数:

    sort filename.txt | uniq -c
    

    其中,-c参数表示同时显示行出现的次数和行。

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.