I have this regex to remove all print statements from a python codebase:
for f in $(find . -name '*.py') ;
do
egrep -v '^[ \t]print ' $f > $f.new
mv $f.new $f
done
but it doesn't really work..
find . -name '*.py' | xargs egrep '^[ \t]*print'
Still prints out the print statements from my code.. :(
However, I want to modify this to comment out all the lines that have print statements in them(so they arent completely gone from the codebase).
How can I efficiently do this? better still is there an automated way to convert everything to logging framework?
[ \t]matches exactly one whitespace. You want[ \t]*.