Tuesday, April 3rd, 2007
cat can have some handy features too.
Another nifty thing I figured out a while ago, whilst having to upload a script written by one of the guys we support, in a windows editor, was how to check quickley and easily with cat(1)whether it had silly windows CR/LF’s :
cat -ev /path/to/file
Would output something like the following if the file had silly line endings…
This is some text written in windaz^M$ And another line edited in windaz, woo^M$
cat suffixes the end of line with a $ and shows any special characters that have been inserted, in our case here ^M is the windows special character for new line, so all you need to do is remove that, which is again pretty easy:
sed -i.bak -sed -e "s/r//g" /path/to/file
Should remove the windaz file endings from the file, copying the file with a .bak suffi as a backup.
Tags: geek, Linux, unix