Re: Editing a output file
Posted in 1999
Assuming the final "|" is the last character in each line, this sed script will work fine: sed 's/\\(^.*\\)|\\([^|]*|$\\)/\\1\\2/' 1 | RAB | Robert A. Banks | 2 | DEC | David R. Cunningham | 3 | MRD | Mathew R. Donaldson | Pipe your output through an executable script that contains the previous sed command. Stacey Windsor wrote: > > > I have a SQL command that runs each night against my database to generate an output > file, but the output is not quite right. The output format is as follows: > > TKID | TKINIT | TKFIRST | TKLAST > > 1 | RAB | Robert A. | Banks | > 2 | DEC | David R.| Cunningham | > 3 | MRD | Mathew R. | Donaldson | > > Is the a way to write a script, use VI or a third party program to edit this file to remove the pipe symbol (and extra space) from between the TKFIRST and TKLAST so that the final format looks like this: > > > 1 | RAB | Robert A. Banks | > 2 | DEC | David R. Cunningham | > 3 | MRD | Mathew R. Donaldson |