# inplace edit with backup perl -pi.bak -e 's/this/that/' ./somefiles* # perl grep perl -ne 'print "$.\t$_" if m/some_re/' ./file.txt