Last active
March 9, 2019 16:09
-
-
Save xbalaji/b47b86fdb927b7142ea5c19f7fcf8bed to your computer and use it in GitHub Desktop.
add line number to a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import sys | |
ifile = open(sys.argv[1], 'r') | |
ofile = open(sys.argv[2], 'w') | |
for c, line in enumerate(ifile, 1): | |
ofile.write("{} {}".format(c,line)) | |
ifile.close() | |
ofile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment