Python: command not found ?


  • -3
    F

    Why we can't use python? It's the year 2015! python has been widely used in system administration long before, every linux distribution has python preinstalled, just like awk and sed. And for complex target like this, python code is much more readable and maintainable than awk/sed or perl

    #! /bin/bash
    
    python - <<-EOF
    M = [line.split() for line in file("file.txt").read().splitlines()]
    for line in zip(*M):
        print " ".join(line)
    EOF
    

    we can get things done with only 2 or 3 lines of python code! I highly doubt if awk or sed can do the same thing decently within 3 lines of code.


  • 0
    C

    why not try changing shebang to #!/bin/env python?


Log in to reply
 

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