Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 2002 03:44:34 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Peter Leftwich <Hostmaster@Video2Video.Com>
Cc:        Warren Block <wblock@wonkity.com>, ann kok <annkok2001@yahoo.com>, FreeBSD Questions <FreeBSD-Questions@FreeBSD.Org>
Subject:   Re: special charaters (return key)
Message-ID:  <20020404014434.GA71781@student.uu.se>
In-Reply-To: <20020403203320.X70185-100000@earl-grey.cloud9.net>
References:  <Pine.BSF.4.21.0204031813590.76705-100000@wonkity.com> <20020403203320.X70185-100000@earl-grey.cloud9.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Apr 03, 2002 at 08:34:57PM -0500, Peter Leftwich wrote:
> On Wed, 3 Apr 2002, Warren Block wrote:
> > On Wed, 3 Apr 2002, ann kok wrote:
> > > how do type the special charater? ^M (return key) I want to remove it on the file
> > > sed 's/^M//g' crt1.txt
> > Seems like last time I wanted to do this, the BSD sed didn't understand that a \r should be a return.  Perl does, though:
> > perl -pi -e 's/\r//g' crt1.txt
> > -Warren Block * Rapid City, South Dakota USA
> 
> This was going to be part of my suggested rememdy (i.e. to use perl) but it
> seemed too complex.  The manpage for "perl" doesn't mention -pi nor does it
> mention -e; Could you explain what this command does?  I think there should
> be a simple command to change a file into one long line :)

'man perl' does not document the switches. 'man perlrun' does.

Briefly:
-e  Next argument is the perl program to run.
-p  Iterate over all the lines in all the files given as arguments.
    Print the result of each step to stdout.
-i  Do the editing inline instead of sending it to stdout. 
    (One can optionally create a backup file.)

So what the program above does is: For each line in each file specified
(crt1.txt above), replace each \r with an empty string, (i.e. remove it.)

To change a file into one long lime you can use the above program. Just
change \r into \n.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020404014434.GA71781>