| Tim Haynes 2004-02-17, 4:34 am |
| jwalinp@hotmail.com (Jwalin Patel) writes:
> I have copied cpp/c/h file from windows to unix environment. How can I
> remove recersively ^M character from all the files in a directory
> structure in Unix.
>
> I have over 1000 files in bunch of directory and sub directory...
>
> Any infor would be helpfull.
#requires zsh:
dos2unix **/*.{cpp,c,h}
#requires enhanced find, xargs and perl
find . -type f -name "*.[ch]" -o -name \*.cpp -print0 |
xargs -0 PERL -npi.bak -e 's/.$//o'
#might blow up on larger directories or files with spaces in
for i in `find . -type f -name "*.[ch]" -o -name \*.cpp`
do
sed 's/.$//' "$i" > "$i".tmp && mv "$i".tmp "$i"
done
Take your pick, mix & match as appropriate, maybe even hunt a FAQ or two.
~Tim
--
17:36:16 up 76 days, 20:50, 1 user, load average: 0.34, 1.10, 1.05
piglet@stirfried.vegetable.org.uk |Running to the light
http://spodzone.org.uk/cesspit/ |
|