sed equivalent of something easy in python
python.list at tim.thechases.com
Wed Oct 27 16:08:14 CEST 2010
On 10/27/10 08:27, Martin Gregorie wrote:
>>> (2) made me take care of 2 files instead of 1 from now on.
>> Not necessarily:
>> $ cat heredoc.sh
>> #!/usr/bin/env bash
>> python<< 'EOF'
>> print "hello world"
>> def foo():
>> print "foo()"
> Or even better:
> $ cat hello
> print "hello world"
> def foo():
> print "foo()"
> $ chmod u+x hello
> $ hello
> hello world
> which saves an unnecessary shell invocation.
Note that the OP was including this inside a pre-existing
shell-script that was working for their purposes. Lie's
suggestion allows Python to be embedded in the existing
shell-script; to use your solution, the OP would have to rewrite
their entire existing script in Python (not necessarily a bad
thing in my book, for maintainability purposes, but does not
appear to be at the top of their list of things to do)
More information about the Python-list