Bash function mac2unix

A new addition to my .bashrc, a bash function that will swap Macintosh newlines for UNIX ones: function mac2unix() { sed 's/\r/\n/gi' } To use it, pipe it as so: cat file.txt.bad-newlines | mac2unix > file.txt This will convert Macintosh newlines from files that Mac friends forgot to upload in ASCII mode. If this is not done, programs will ignore the Macintosh newlines and files will have no newlines, which goes without saying is very annoying.

Like this article? Please support my writing! Flattr my blog (see my thoughts on Flattr), tip me via PayPal, or send me an item from my Amazon wish list.