Guest User

Untitled

a guest
Apr 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/usr/bin/python
  2. # easy 'dos2unix' script
  3. # todo:
  4. # - make sure all arguments are files
  5. # - use temporary files
  6.  
  7. import sys
  8. from shutil import move
  9.  
  10. for file in sys.argv[1:]:
  11. newfile = file + ".new"
  12. nf = open(newfile, 'w')
  13. for line in open(file):
  14. nl = line.rstrip() + '\n'
  15. nf.write(nl)
  16. # move .new file onto original
  17. move(newfile, file)
Add Comment
Please, Sign In to add comment