Rustom Mody wrote: > On Friday, May 30, 2014 12:15:46 PM UTC+5:30, Rustom Mody wrote: >> Heres a (poooor) approx >> >> $ python -c 'import os, pprint; pprint.pprint ([ r for r, d, f in >> os.walk(".") if len(d+f) != 1])' > > Without pprint: (pooor) > > python -c 'import os; print "\n".join([ r for r, d, f in os.walk(".") if > len(d+f) != 1])' > > Or (poor) > > python -c 'from os import walk; print "\n".join([ r for r, d, f in > walk(".") if len(d+f) != 1])'
If there are a lot of matching folders: $ python -c 'import os, sys; sys.stdout.writelines(p + "\n" for p, f, n in os.walk(".") if len(n+f) == 1)' With a little help from the shell: $ echo -e "import os\nfor p, f, n in os.walk('.'):\n if len(f+n) == 1: print(p)" | python -- https://mail.python.org/mailman/listinfo/python-list