Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dropping a column into a VI file

0 views
Skip to first unread message

JAW

unread,
Nov 9, 2009, 12:57:24 PM11/9/09
to
I have a large file I have started adding POSITION commands to for
Oracle SQL Loader.

%s /$/POS etere/ will get me the commands; however, I want them
all stacked in the same column for readibility.

How could I do that with regular expressions in VI?

Basically, POSTION(XX,,XX) DECIMAL EXTERNAL all in proper column and
then I can clean-up after that.


M_KY_BA POSITION (1,10) DECIMAL EXTERNAL,
M_LOCATION POSITION (10,14) DECIMAL EXTERNAL,
M_PREM_NO POSITION (XX,XX) DECIMAL EXTERNAL,
M_CUST_NO
M_SSN
M_TX_OFFICE
M_DATE_MDY
M_BILL_GR
M_PREV_DATE_MDY
M_BILL_FL
M_SPT_GAS_CTAR
M_NAME1
M_NAME2
M_ADDRESS1
M_ADDRESS2
M_ADDRESS3
M_ADDRESS4
M_MRDG_SEQ_NO

Janis Papanagnou

unread,
Nov 9, 2009, 1:56:33 PM11/9/09
to
JAW wrote:
> I have a large file I have started adding POSITION commands to for
> Oracle SQL Loader.
>
> %s /$/POS etere/ will get me the commands; however, I want them
> all stacked in the same column for readibility.
>
> How could I do that with regular expressions in VI?

For editor questions comp.editors is more appropriate.

>
> Basically, POSTION(XX,,XX) DECIMAL EXTERNAL all in proper column and
> then I can clean-up after that.

A way to do that formatting in shell with your data...

while read -r M P C rest
do printf "%-20s %-20s %-20s \n" "$M" "$P $C" "$rest"
done <infile >outfile

And you can of course add also the "POS etere" to the end of the
printf format string so you don't need the manual vi'ing.

Janis

sandy

unread,
Dec 11, 2009, 3:09:14 PM12/11/09
to
On Mon, 09 Nov 2009 09:57:24 -0800, JAW wrote:

I used that utility some, back in the late 1990s.
But jumped on perlDBI the minute it became available
(write re-usable modules, parse on white
space instead of hard-coded byte positions, etc).

0 new messages