From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,62951c700994df34 X-Google-Attributes: gidfee84,public X-Google-Thread: 107393,62951c700994df34 X-Google-Attributes: gid107393,public X-Google-Thread: f9400,62951c700994df34 X-Google-Attributes: gidf9400,public From: peter@nmti.com (Peter da Silva) Subject: Re: Unix editors w/features for dealing with columnar data? Date: 1995/05/03 Message-ID: #1/1 X-Deja-AN: 101999058 distribution: inet sender: peter@nmti.com (peter da silva) references: <3nr6nl$cak@news.iastate.edu> organization: Network/development platform support, NMTI newsgroups: comp.editors,comp.os.ultrix,comp.unix.osf.osf1 In article <3nr6nl$cak@news.iastate.edu>, Charles F Randall wrote: > We're moving a large numbers of users from a mainframe environment to > Unix. Some of them have large data files which can be described in the > following manner: (trivial example) > > Columns Description > ------- ----------- > 1-4 id number > 5-24 name > 25-30 dat1 > 30-35 dat2 > ... etc > > In essence, they've got what I call fixed column data. (not whitespace > separated - I'm mainframe-challenged, sorry for the wording) They're > used to using Stanford Wylbur (not the same as some commercial Wylbur > implementations) to do their editing tasks. > > They do things like: > Here's how you do these in ed/edit/ex/vi/sed... > Find the lines that have '1234' in columns 1-4 and change > columns 30-35 to 'abcdef'. g/^1234/s/^\(.............................\)....../\1abcdef/ > > Find the lines with '1234' in columns 1-4 and 'dog' starting in > column 5 and insert three spaces starting in column 25. g/^1234dog/s/^\(........................\)/\1 / > Find the lines with 'dog' starting in column 5 and copy columns 25-30 > to 30-35. g/^....dog/s/^\(........................\)\(......\)...../\1\2\2/ > Find the lines longer than 35 characters and replace columns 5-24 > with 'invalid' (left justified, blank padded) g/^.................................../s/^\(....\)..................../\1invalid / > Change the 2nd and 5th occurrences of 'dog' in lines 300-450 to 'cat'. 300,450s/^\(.*dog.*\)dog\(.*dog.*dog.*\)dog/\1cat\2cat/ > Is anyone familiar with an editor in the Unix environment with extensive > columnar manipulation features like this? I assume that the Wylbur commands for the above are more convenient, but it's possible in ex/vi. -- Peter da Silva `-_-' Network Management Technology Incorporated 'U` 1601 Industrial Blvd. Sugar Land, TX 77478 USA +1 713 274 5180 "Har du kramat din varg idag?"