Converting a comma delimited file to newline delimited. Using sed to perform the conversion.

Posted: August 23, 2011. At: 2:13 PM. This was 6 years ago. Post ID: 1845

Gedit search and replace dialog.
Gedit search and replace dialog.

The search and replace dialog in Gedit. I have used this to convert a comma delimited file to a newline delimited file. I had saved a huge long list of IP addresses that I had to put into the banlist on my forums, and the list was comma delimited, but the latest PHPBB software will not accept that and it has to be newline delimited. Therefore I used this to convert the list to a newline delimited format and then it worked perfectly. Putting the banlist into your PHPBB forums will cut down on a massive amount of spam that would normally overwhelm your forums. The ability to convert an entire file from one format to another with one command is why this tip is so useful.

This can also be achieved by typing this in a terminal emulator window.

cat banlist.txt | sed s'/, /\n/gi'; > banlistnewline.txt

Using sed makes this very simple. This is why the Linux shell is so powerful, the many commands you can use to manage text files and redirection as well as the power of sed and awk make the Linux shell very useful indeed.

No comments have been made. Use this form to start the conversation :)

Leave a Reply