[wplug] vi question
Doms, Robert S
rsdoms at switch.com
Thu Jul 3 11:26:43 EDT 2003
I use this perl script to fix the ^M issue. It creates a file
filename.strip that is ^M free. I then copy the .strip file back over the
original file. The script removes the first character preceeding a newline.
In this case, the ^M. Hope it helps.
Scott
strip_ems.pl
#!/usr/local/bin/perl
if( $#ARGV != 0 ) {
print"\n\aCaution! This file will remove *ALL* characters imediately
preceeding a newline!!";
print"\nUsage: strip_ems [ filename ]\n\n";
}
open( FD, "<$ARGV[0]" );
open( OUTD, ">$ARGV[0].strip" );
while( <FD> ) {
$_ =~ s/.$//;
print OUTD $_;
}
> -----Original Message-----
> From: John Harrold [SMTP:jmh17 at pitt.edu]
> Sent: Thursday, July 03, 2003 11:21 AM
> To: wplug at wplug.org
> Subject: Re: [wplug] vi question
>
> Sometime in July Scott Eicher assaulted the keyboard and produced:
>
> |
> | For you vi users I have a question:
> |
> | I would like to delete all ^M control characters from an ascii file.
> Here is
> | what I tried to accomplish this but it doesn't work:
> |
> | :%s/\^M//g
> |
>
> instead of the carrot+M combination try ctrl+q ctrl+m. this should stick a
> little blue, or whatever color, ^M there.
>
> | It gives me this message:
> |
> | Substitute pattern match failed
> |
> | I'm thinking that I'm not specifying the ^M properly but I'm not sure
> how
> | else to specify it.
> |
> | Any help would be appreciated.
> |
> | Thanks,
> | Scott
>
> --
> --------------------------------------------------------------------------
> | /"\
> john harrold | \ / ASCII ribbon campaign
> jmh at member.fsf.org | X against HTML mail
> the most useful idiot | / \
> --------------------------------------------------------------------------
> What difference does it make to the dead, the orphans, and the homeless,
> whether the mad destruction is brought under the name of totalitarianism
> or
> the holy name of liberty and democracy?
> --Gandhi
> --------------------------------------------------------------------------
> gpg --keyserver keys.indymedia.org --recv-key F65A739E
> --------------------------------------------------------------------------
More information about the wplug
mailing list