python -c option

Mike Mike at kordik.net
Sun Jul 6 16:42:06 EDT 2003


I am very new to Python and read the docs section about having python run
commands from the command line. I have been successful with:

python -c "print 'Hello'"

It prints Hello

In the interpreter I can type 2+2 and it will return 4 but how do I do
that from the command line? I have tried a few things without success.

What I am really after is to do some command line processing where the
output of grep is returning "prog=.01234" and I want to beautify it so it
prints "12%"

Maybe I should mess with bash but I am new to *nix in general and I wanted
to learn Python.

Thanks,
Mike




More information about the Python-list mailing list