Fortunately it is easy to fix the files, either in Vim itself, or with a little script I cooked up to do the job on a bunch of files all at once, here it is...
#!/bin/sh
#
# File name: mac2unix.sh
# Date: 2008/10/11 08:57
# Author: Nigel Houghton
# $Id: $
# Copyright: (c) Sourcefire Inc. 2008
#
if [ "$1" = "" ]
then
echo "Usage: $0 filename1 filename2...."
exit
fi
FILES="$@"
changeit () {
OLDNAME="$file"
NEWNAME="$file.tmp_$$"
tr \\r \\n < $OLDNAME > $NEWNAME
mv $NEWNAME $OLDNAME
}
for file in $FILES
do
changeit
done
Of course, this could be done in several different ways and it could be extended for other systems (Windows for example) that use other line ending schemes. I put this script in my
$HOME/bin/
so I can use it from wherever I happen to be in the filesystem.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.