perl -i.bak -pe 's/^\s\s\s\s(.*)$\n\s\s\s\s/$1/g' myfile.txt perl -i.bak -pe 's/\n\s\s\s\s/ /gm' myfile.txt