[wplug] Converting Line Terminations

Beth Skwarecki skwareea at screech.cs.alfred.edu
Thu Feb 7 15:25:10 EST 2002


> If you are referring to the ^M at the end of Windows files in *nix try this
> c-code:
> 
> #include <stdio.h>
> 
> main()
> {
>   char s[200];
>   int i;
>   while( gets(s) != NULL ){
>     for(i=0;i<strlen(s);i++){
>       if( strcmp(&s[i],"\r") != 0)
>  putchar(s[i]);
>     }
>     putchar('\n');
>   }
> }
> 
> 
> It should remove the carriage returns and make things better.
> Emilio

Or: 

cat file.txt | perl -pe 's/\n\r/\n/;' > outputfile.txt

isn't perl great? :-)

-- 
Beth Skwarecki
http://www.loxosceles.org/

Paranoid Club meeting this Friday.  Now ... just try to find out where!



More information about the wplug mailing list