home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / shell / 5217 < prev    next >
Encoding:
Text File  |  1992-12-31  |  1010 b   |  47 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!psinntp!jpradley!jpr
  3. From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
  4. Subject: Re: stripping cr/lf's
  5. Date: Thu, 31 Dec 1992 21:12:54 GMT
  6. Message-ID: <1992Dec31.211254.12888@jpradley.jpr.com>
  7. References: <1992Dec31.071312.6153@netcom.com>
  8. Organization: Unix in NYC
  9. Lines: 36
  10.  
  11. In article <1992Dec31.071312.6153@netcom.com> kasajian@netcom.com (Kenneth Kasajian) writes:
  12. >
  13. >How do I strip the cr's from a text file?  There must be a standard
  14. >unix way of doing it!
  15.  
  16.  
  17. SCO, at least, provides dtox, and the reverse, xtod.
  18.  
  19. In ex, just
  20.     %s/^V^M//
  21.  
  22. Or use this script:
  23.  
  24.     :
  25.     # addcr : adds CRs
  26.     # delcr : removes CRs
  27.     [ $# -ne 2 ] && echo Usage\: $0 infile outfile && exit
  28.     case $0 in
  29.         *addcr) sed s+$++ <$1 >$2;;
  30.         *delcr) sed s---g <$1 >$2;;
  31.     esac
  32.  
  33.  
  34. or this one:
  35.  
  36.     :
  37.     # cr+-: adds CR's if they're not present, deletes them if they are.
  38.     # use as a filter
  39.     sed '
  40.     s---g
  41.     t
  42.     s+$++
  43.     t
  44.     '
  45. -- 
  46. Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160.1341
  47.