for file in $(find /path/to/dir -type f); do
tr -d '\r' <$file >temp.$$ && mv temp.$$ $file
done
In order to give credit where it's due, a user named blowtorch gave the tip at the following forum.
A blog dedicated to text editing and general exploration of computing knowledge
for file in $(find /path/to/dir -type f); do
tr -d '\r' <$file >temp.$$ && mv temp.$$ $file
done
9 comments:
In vi, you can strip out all \r's with :%s/^V^M//g
You can do this in place using gnu sed with the -i option.
for file in $(find /path -type f); do
sed -i 's/\r//g' $file; done
You can also get out some decent mileage out of dos2unix -- no temp file needed, either. And the name is catchy. ;)
You could use find to do this, I think with
$ find /path/to/files -name "*.c" -exec dos2unix {} +
See the manpage for find for complete details, but the -exec option here replaces {} with matched filenames and the '+' signifies that dos2unix can take multiple filenames. If it doesn't, replace '+' with '\;', backslash required so the semicolon is not interpreted by the shell.
Oh yeah, and dos2unix is part of the 'tofrodos' package, at least on debian/ubuntu.
Of course, the "-b" flag to diff may also be of use. It'll ignore all differences in the amount of whitespace, so it'll typically only catch any significant differences (unless you're comparing Python code ;-)).
Off topic, but does anyone know how to pass an ex command to vim at startup?
Thanks.
Casey
To clarify what I'm trying to do, a script of mine needs to launch VIM and the vert diffs command.
Casey
@casey
vimdiff?
Post a Comment