|
Prev: How do you update a Makefile?
Next: Make file problem
From: injam4u on 1 Jul 2008 02:59 Hi, I have the following file swadmin(a)tb142:/rangedoms1/working/ CRST_OVERLAY_ENHANCE_Analysis_RNGCTRL_DEV> cat exp_aovr_send_new.dat 0001349000174P00000012D-ATPNB050062184TPNB050063880 0001349000174P60000329C-ATPNB050064199TPNB050064268 Now i need the above file in the below format i.e splitting up of range character 23 to 25 in each record. Resulting file ____________________ 0001349000174P00000012DTPNB050062184TPNB050063880 0001349000174P00000012CTPNB050062184TPNB050063880 0001349000174P00000012BTPNB050062184TPNB050063880 0001349000174P00000012ATPNB050062184TPNB050063880 0001349000174P60000329CTPNB050064199TPNB050064268 0001349000174P60000329BTPNB050064199TPNB050064268 0001349000174P60000329ATPNB050064199TPNB050064268
From: Robert Harris on 1 Jul 2008 04:36 injam4u(a)gmail.com wrote: > Hi, > I have the following file > swadmin(a)tb142:/rangedoms1/working/ > CRST_OVERLAY_ENHANCE_Analysis_RNGCTRL_DEV> cat exp_aovr_send_new.dat > 0001349000174P00000012D-ATPNB050062184TPNB050063880 > 0001349000174P60000329C-ATPNB050064199TPNB050064268 > > Now i need the above file in the below format i.e splitting up of > range character 23 to 25 in each record. > Resulting file > ____________________ > 0001349000174P00000012DTPNB050062184TPNB050063880 > 0001349000174P00000012CTPNB050062184TPNB050063880 > 0001349000174P00000012BTPNB050062184TPNB050063880 > 0001349000174P00000012ATPNB050062184TPNB050063880 > 0001349000174P60000329CTPNB050064199TPNB050064268 > 0001349000174P60000329BTPNB050064199TPNB050064268 > 0001349000174P60000329ATPNB050064199TPNB050064268 Read the output of: "man cut" Robert
From: John W. Krahn on 1 Jul 2008 07:28 injam4u(a)gmail.com wrote: > Hi, > I have the following file > swadmin(a)tb142:/rangedoms1/working/ > CRST_OVERLAY_ENHANCE_Analysis_RNGCTRL_DEV> cat exp_aovr_send_new.dat > 0001349000174P00000012D-ATPNB050062184TPNB050063880 > 0001349000174P60000329C-ATPNB050064199TPNB050064268 > > Now i need the above file in the below format i.e splitting up of > range character 23 to 25 in each record. > Resulting file > ____________________ > 0001349000174P00000012DTPNB050062184TPNB050063880 > 0001349000174P00000012CTPNB050062184TPNB050063880 > 0001349000174P00000012BTPNB050062184TPNB050063880 > 0001349000174P00000012ATPNB050062184TPNB050063880 > 0001349000174P60000329CTPNB050064199TPNB050064268 > 0001349000174P60000329BTPNB050064199TPNB050064268 > 0001349000174P60000329ATPNB050064199TPNB050064268 $ echo "0001349000174P00000012D-ATPNB050062184TPNB050063880 0001349000174P60000329C-ATPNB050064199TPNB050064268" | \ perl -ne' s[(.)-(.)][.]; ($a,$b,$i)=($1,$2,$-[0]); @x=${a}gt$b?reverse$b..$a:$a..$b; for$x(@x){substr$_,$i,1,$x;print} ' 0001349000174P00000012DTPNB050062184TPNB050063880 0001349000174P00000012CTPNB050062184TPNB050063880 0001349000174P00000012BTPNB050062184TPNB050063880 0001349000174P00000012ATPNB050062184TPNB050063880 0001349000174P60000329CTPNB050064199TPNB050064268 0001349000174P60000329BTPNB050064199TPNB050064268 0001349000174P60000329ATPNB050064199TPNB050064268 John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall
From: shakahshakah on 1 Jul 2008 12:34 On Jul 1, 2:59 am, inja...(a)gmail.com wrote: > Hi, > I have the following file > swadmin(a)tb142:/rangedoms1/working/ > CRST_OVERLAY_ENHANCE_Analysis_RNGCTRL_DEV> cat exp_aovr_send_new.dat > 0001349000174P00000012D-ATPNB050062184TPNB050063880 > 0001349000174P60000329C-ATPNB050064199TPNB050064268 > > Now i need the above file in the below format i.e splitting up of > range character 23 to 25 in each record. > Resulting file > ____________________ > 0001349000174P00000012DTPNB050062184TPNB050063880 > 0001349000174P00000012CTPNB050062184TPNB050063880 > 0001349000174P00000012BTPNB050062184TPNB050063880 > 0001349000174P00000012ATPNB050062184TPNB050063880 > 0001349000174P60000329CTPNB050064199TPNB050064268 > 0001349000174P60000329BTPNB050064199TPNB050064268 > 0001349000174P60000329ATPNB050064199TPNB050064268 Using awk: jc(a)jc-ubuntu:~$ cat /tmp/sample.data 0001349000174P00000012D-ATPNB050062184TPNB050063880 0001349000174P60000329C-ATPNB050064199TPNB050064268 jc(a)jc-ubuntu:~$ awk 'BEGIN { FS="-"; for(i=0; i<255; ++i) asc[sprintf("%c",i)] = i; } /.-./ { p1=substr($1,1,length($1)-1); p2=substr($2,2); chhi=asc[substr($1,length($1))]; chlo=asc[substr($2,1,1)]; for(; chhi>=chlo; chhi--) { print p1 sprintf("%c",chhi) p2 } }' < /tmp/sample.data 0001349000174P00000012DTPNB050062184TPNB050063880 0001349000174P00000012CTPNB050062184TPNB050063880 0001349000174P00000012BTPNB050062184TPNB050063880 0001349000174P00000012ATPNB050062184TPNB050063880 0001349000174P60000329CTPNB050064199TPNB050064268 0001349000174P60000329BTPNB050064199TPNB050064268 0001349000174P60000329ATPNB050064199TPNB050064268 AWK script formatted for readability: BEGIN { FS="-" for(i=0; i<255; ++i) asc[sprintf("%c",i)] = i } /.-./ { p1=substr($1,1,length($1)-1) p2=substr($2,2) chhi=asc[substr($1,length($1))] chlo=asc[substr($2,1,1)] for(; chhi>=chlo; chhi--) { print p1 sprintf("%c",chhi) p2 } }
|
Pages: 1 Prev: How do you update a Makefile? Next: Make file problem |