Tuesday, January 22, 2013

Using tr to delete carriage returns

I wanted to change a files contents from being carriage return delimited to being space delimited, So of course I tried to pipe it through sed, but couldn't get it to do what I needed for whatever reason.

Found the "tr" command for "translate characters".

Can use -d option to delete chracters
tr -d "\n" < file.txt > file-sans-cr.txt
or give two strings to translate between
tr "\n" " " < file.txt > space-delimited-file.txt

No comments:

Post a Comment