I am attempting the perl to python transition and I also happen to use lots of perl one-liners in the bash prompt for parsing files. For example,
cat input_file.txt|perl -ne 'chomp $_; @a=split /\t/,$_;print "$_\n" if ($a[3]>=50)' > output_file.txt
loops through through the file and prints only those lines that have the 4th column with a value greater than 50. This is accomplished with the "perl -ne" flag.
My question: Does python have an equivalent to "perl -ne" or have any other flags beyond "python -c" for taking commands from the prompt? Most solutions I have seen for using python commands from the prompt are ugly and would be solved with the use of such switches.
If not, I'll just have to use perl for on the fly one liners and python for scripting
Thanks!