home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!ucbvax!EQL.CALTECH.EDU!rankin
- From: rankin@EQL.CALTECH.EDU (Pat Rankin)
- Newsgroups: comp.os.vms
- Subject: Re: Help on "simple" EVE/TPU procedure
- Message-ID: <921222165417.20400822@EQL.Caltech.Edu>
- Date: 23 Dec 92 00:55:36 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 30
-
- > I am trying to clean up large amounts of Fortran code which
- > contains "junk" in each record of each file, beyond the
- > 72-nd character position in each record.
- >
- > Is it relatively simple to get TPU to truncate each record
- > in a file at the 72-nd character position?
- > (After that, it would be nice to have TPU delete all
- > trailing blanks after the lines of code, but that's not
- > as important as the first task.)
-
- It should be pretty simple to do in TPU, or DCL for that matter,
- but there are other tools to consider. You could do it with a one-liner
- in awk (well, it's 3 statements but they fit comfortably on 1 line :-).
- Using gawk, it would be
- $ gawk "{ $0 = substr($0,1,72); sub(/ +$/,""""); print }" <infile >outfile
- (The lump of quotes in the middle is just "" inside a DCL quoted string.)
- A more elaborate program could process a whole directory full of files
- in a single run.
-
- There's another utility available which is even better suited for
- this particular task: EXTRACT.
- $ extract/columns=(1:72)/edit=(strip_trailing) infile/output=outfile
- would do precisely what you're asking for. It's available via FTP from
- hamlet.caltech.edu in [.rankin]extract.vms_share, but you'll need the
- VAX FORTRAN compiler to build it. A slightly older version is avaiable
- from the DECUS Fall'90 VAX/L&T SIG tape. (Warning: that one had a bug
- in the /columns qualifier which is fixed in the vms_share'd sources.)
-
- Pat Rankin, rankin@eql.caltech.edu
-
-