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: , ,

» Filed under General Life, Linux by Chris Ganderton at 21:56.

back to top

Leave a comment







Credits and stuff

Copyright © [ t h e f r a g g l e . c o m ] | Powered by WP 2.3.1. | Tree by Headsetoptions and MandarinMusing a minimal theme based on HyperBallad Back to Content