0

When I type python in a shell I get >>> as a result. Then if I type print "something", it prints something. I want to do both in a single command via bash script. Here is an example that doesn't work but is close to getting the point across

`print "something"` | python;

I would expect python to be executed and the print command to be passed as an argument. But this is not the case.

How can I do this:

python
>>> print "hello"

in one command?

John Kugelman
365k70 gold badges555 silver badges600 bronze badges
asked Apr 11, 2013 at 3:45

2 Answers 2

4

How about:

python -c "print 'hello'"
answered Apr 11, 2013 at 3:47
Sign up to request clarification or add additional context in comments.

Comments

0

You would need to write it as

echo 'print "something"' | python

or

printf 'print "something"' | python

but Bhajun's answer is what you really want.

answered Apr 11, 2013 at 12:46

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.