I vaguely recall being able to do something like this in Python:
cat foo | python -c "<some python code>" | grep blah | ...
For some reason I'm blanking on how to actually use this to run Python code on each line of the input file. For instance, say I wanted to change every instance of the word "apple" in the original file to "orange"; how would I do that?
I don't see how this can be helpful more than once, but here's a one-liner:
cat file | grep apple | python -c "for line in __import__('sys').stdin: print line.replace(\"apple\", \"orange\"),"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With