#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    45
    Rep Power
    5

    linux fold command in python


    Is there a easy way to use a unix fold command in python. I want to use it like :

    Code:
    fold -w 80 input.txt >> output.txt
    I have tried the textwrap module, but it works very slow in my 7gb input file.

    Thanks for your consideration.
    Last edited by utpalmtbi; August 8th, 2016 at 02:34 PM.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,843
    Rep Power
    509
    import os
    os.system('fold -w 80 input.txt >> output.txt')


    of course we're told to us the subprocess module these days.

    https://docs.python.org/3/library/su...cing-os-system

    Comments on this post

    • utpalmtbi agrees
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo