home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!psinntp!jpradley!jpr
- From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
- Subject: Re: stripping cr/lf's
- Date: Thu, 31 Dec 1992 21:12:54 GMT
- Message-ID: <1992Dec31.211254.12888@jpradley.jpr.com>
- References: <1992Dec31.071312.6153@netcom.com>
- Organization: Unix in NYC
- Lines: 36
-
- In article <1992Dec31.071312.6153@netcom.com> kasajian@netcom.com (Kenneth Kasajian) writes:
- >
- >How do I strip the cr's from a text file? There must be a standard
- >unix way of doing it!
-
-
- SCO, at least, provides dtox, and the reverse, xtod.
-
- In ex, just
- %s/^V^M//
-
- Or use this script:
-
- :
- # addcr : adds CRs
- # delcr : removes CRs
- [ $# -ne 2 ] && echo Usage\: $0 infile outfile && exit
- case $0 in
- *addcr) sed s+$++ <$1 >$2;;
- *delcr) sed s---g <$1 >$2;;
- esac
-
-
- or this one:
-
- :
- # cr+-: adds CR's if they're not present, deletes them if they are.
- # use as a filter
- sed '
- s---g
- t
- s+$++
- t
- '
- --
- Jean-Pierre Radley Unix in NYC jpr@jpr.com jpradley!jpr CIS: 72160.1341
-