perl -p -e "s/\r+//" file.txt > newfile.txt #### while (){ /ATDT\d+\s+BUSY/ ? print : print "Did not match '$_'\n"; #print if /ATDT\d+\s+BUSY/; #print if /ATDT\d+.*BUSY/s; #print; } #### The system cannot find the file specified. #### Did not match 'Output: Got ."ATDT1234567' ' Did not match 'BUSY