Inline string replacement with Perl:
perl -p -i -e 's/5005P/500P /g' /path/to/files/filename_date_2015*.txt perl -p -i -e 'BEGIN{undef $/;} s/.*<pre>//smg' history_file.txt