python provides a
-c option to accept and run a script line.
To reverse a string like this one: “toydi deified idiot”.
echo 'toydi deified idiot' | python -c "print raw_input()[::-1]"
echoprints the string to stdout.
pythonrun the script line.
raw_input()read from stdin (to read from pipe and return the string).
[::-1]simply says: steps through and return each character in the string, but in reverse order (-1).
toidi deified idyot
Have fun with python!
Wait.. ok, actually,
rev will just do the job:
echo "toidi deified idyot" | rev