perl -i.bak -pe "BEGIN { binmode STDOUT } s/(?=\[)/\r\n/g" file #### perl -i.bak -pe "s/(?=\[)/\n/g" file