perl -ple's/^line\d+=//' infile | perl -p0e 's!\n!/!g' > outfile #### perl -ple's/^line\d+=//' infile | perl -p0e 's!\s+$!! ; s!\n!/!g' > outfile