murillo@sigi.Colorado.EDU (Rodrigo Murillo) (04/19/88)
I have an SED problem (I think) and I would like to get som feedback on how to do this. It is pretty trivial I think, but I am new to SED. I have a text file of this form: BEGIN 1 2 3 END BEGIN 4 5 6 END This goes on for about 200 records. What I want to do is extract the numbers, in the same sequence as in the original, and write them out to a new file. Obviously, the result should be: 1 2 3 4 5 6 . . . Also, I have recently had text files that have an emmbeded ^M char at the end of every line. I know this has something to do with CR/LF conversion. But how do I get rid of it? Thanks. Rod. -- _______________________________________________________________________________ Rodrigo Murillo, University of Colorado - Boulder (303) 761-0410 murillo@boulder.colorado.edu | ..{ncar|nbires}!boulder!murillo ( Machines have less problems. I'd like to be a machine. -- Andy Warhol )
wnp@dcs.UUCP (Wolf N. Paul) (04/20/88)
In article <5483@sigi.Colorado.EDU> murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: > >Also, I have recently had text files that have an emmbeded ^M char >at the end of every line. I know this has something to do with >CR/LF conversion. But how do I get rid of it? Thanks. > tr -d '\015' < infile > outfile This works on System V -- I don't know if the BSD version of tr(1) understands the -d option (== delete specified chars), or if it understands octal escapes. -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: ihnp4!killer!dcs!wnp ESL: 62832882 INTERNET: wnp@EESDES.DAS.NET or wnp@dcs.UUCP TLX: 910-280-0585 EES PLANO UD
brown@nicmad.UUCP (Mr. Video) (04/21/88)
In article <62@dcs.UUCP> wnp@dcs.UUCP (Wolf N. Paul) writes: <In article <5483@sigi.Colorado.EDU> murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: < > < >Also, I have recently had text files that have an emmbeded ^M char < >at the end of every line. I know this has something to do with < >CR/LF conversion. But how do I get rid of it? Thanks. < > < <tr -d '\015' < infile > outfile < <This works on System V -- I don't know if the BSD version of tr(1) understands <the -d option (== delete specified chars), or if it understands octal escapes. We have a little utility written in C, for 4.3BSD, that will remove (delcr) or add (addcr) carriage returns from/to a file. -- harvard-\ ihnp4--\ Mr. Video !uwvax.................!nicmad!brown rutgers-/ terminus-/ decvax--/
was@creare.UUCP (Wayne Smith) (04/21/88)
In article <5483@sigi.Colorado.EDU> murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: >I have an SED problem (I think) and I would like to get som feedback >on how to do this. It is pretty trivial I think, but I am new to SED. > >I have a text file of this form: > > BEGIN > 1 > 2 > 3 > END > > BEGIN > 4 > 5 > 6 > END > >This goes on for about 200 records. What I want to do is extract the >numbers, in the same sequence as in the original, and write them out to >a new file. #!/bin/sh # Remove everything not between BEGIN and END sed -n -e '/^BEGIN$/!d :a n /^END$/d p b a' $1 >Also, I have recently had text files that have an emmbeded ^M char >at the end of every line. I know this has something to do with >CR/LF conversion. But how do I get rid of it? Thanks. sed 's/^M$//' (Note: the ^M is a single character. In vi or on the command line, type ^V^M to get the ^M into the text.) -Wayne Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. Ignore these lines. Seems my solution wasn't verbose enough for the mailer. -- Wayne A. Smith Creare Inc. arpa: was%creare%dartmouth.edu@relay.cs.net P.O. Box 71 uucp: dartvax!creare!was Hanover, NH 03755 phone: (603) 643-3800
seth@tuba.columbia.edu (Seth Robertson) (04/22/88)
In article <2623@nicmad.UUCP> brown@nicmad.UUCP (Mr. Video) writes: >In article <62@dcs.UUCP> wnp@dcs.UUCP (Wolf N. Paul) writes: ><In article <5483@sigi.Colorado.EDU> murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: >< > >< >Also, I have recently had text files that have an emmbeded ^M char >< >at the end of every line. I know this has something to do with >< >CR/LF conversion. But how do I get rid of it? Thanks. >< > >< ><tr -d '\015' < infile > outfile >< ><This works on System V -- I don't know if the BSD version of tr(1) understands ><the -d option (== delete specified chars), or if it understands octal escapes. > >We have a little utility written in C, for 4.3BSD, that will remove (delcr) >or add (addcr) carriage returns from/to a file. If it not an automated processs, and you want to do it by hand, I usually just find it easier to do it in emacs.. load the file and then do Meta-% ^q^m<ret> <ret> -seth ------------------------------------------------------------------------------- ** Seth Robertson a.k.a Earendur Ranger 35th Lord of Andunie in Numenor ** ** Center for Telecommunications Research at Columbia University ** ** ------------------------------------------------------------------------- ** ** #include <std/disclaimer.h> "There is no right. There is only Power" ** ** ------------------------------------------------------------------------- ** ** seth@ctr.columbia.edu sjr@cunixc.columbia.edu ** ** !uunet!columbia!ctr.columbia!seth rjs!cxinuc!aibmuloc!tenuu! ** ** 706 John Jay; Columbia University; NYC 10027 (212) 280-6107 ** -------------------------------------------------------------------------------