How to find the particular text stored in the file “data.txt” and it occurs only once

前端 未结 8 1624
暗喜
暗喜 2021-01-11 17:37

The line I seek is stored in the file data.txt and is the only line of text that occurs only once.

How do I go about finding that particular line using linux?

8条回答
  •  孤街浪徒
    2021-01-11 18:23

    Add more information to you post. How data.txt look like? Like this:

    11111111
    11111111
    pass1111
    11111111
    

    Or like this

    afawfdgd
    password
    somethin
    gelse...
    

    And, do you know the password is in file or you search for not repeat string.

    If you know password, use something like this

    cat data.txt | grep 'password'

    If you don`t know the password and this password is only unique line in file you must create a script. For example in Python

    file = open("data.txt","r")
    f = file.read()
    for line in f: 
       if 'pass' in line:
            print pass
    

    Of course replace pass with something else. For example some slice from line.

提交回复
热议问题