How to get some specific lines from huge text file in unix?

前端 未结 3 599
悲哀的现实
悲哀的现实 2021-02-01 20:34

I use importing systems based on delimited text files. The files used can sometimes be almost 2 Gb big and I have to check some lines from that file. So I want to know how ca

3条回答
  •  伪装坚强ぢ
    2021-02-01 21:15

    In python:

    readThisFile = open('YOURFILE')
    outputFile = open('OUTPUT', w)
    
    for actualline, linetext in enumerate(readThisFile):
        if actualline == WANTEDLINE
            outputFile.write(linetext)
        else:
            pass
    

    If wanted you can modify that script to work with arguments (like getline.py 1234)

提交回复
热议问题