Print file in reverse with line-numbers


  • 0
    J

    Given a file, test.txt:

    Line 0
    Line 1
    Line 2
    

    Print to stdout:

    0 Line 2
    1 Line 1
    2 Line 0
    

    Suggested 1-liner answer:

    tac test.txt | nl -v 0

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.