Hi,
I have the following file
swadmin@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
|
|
0
|
|
|
|
Reply
|
injam4u (13)
|
7/1/2008 6:59:14 AM |
|
injam4u@gmail.com wrote:
> Hi,
> I have the following file
> swadmin@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
|
|
0
|
|
|
|
Reply
|
robert.f.harris (386)
|
7/1/2008 8:36:04 AM
|
|
injam4u@gmail.com wrote:
> Hi,
> I have the following file
> swadmin@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
|
|
0
|
|
|
|
Reply
|
someone4 (105)
|
7/1/2008 11:28:23 AM
|
|
On Jul 1, 2:59=A0am, inja...@gmail.com wrote:
> Hi,
> I have the following file
> swadmin@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@jc-ubuntu:~$ cat /tmp/sample.data
0001349000174P00000012D-ATPNB050062184TPNB050063880
0001349000174P60000329C-ATPNB050064199TPNB050064268
jc@jc-ubuntu:~$ awk 'BEGIN { FS=3D"-"; for(i=3D0; i<255; ++i)
asc[sprintf("%c",i)] =3D i; } /.-./ { p1=3Dsubstr($1,1,length($1)-1);
p2=3Dsubstr($2,2); chhi=3Dasc[substr($1,length($1))];
chlo=3Dasc[substr($2,1,1)]; for(; chhi>=3Dchlo; chhi--) { print p1
sprintf("%c",chhi) p2 } }' < /tmp/sample.data
0001349000174P00000012DTPNB050062184TPNB050063880
0001349000174P00000012CTPNB050062184TPNB050063880
0001349000174P00000012BTPNB050062184TPNB050063880
0001349000174P00000012ATPNB050062184TPNB050063880
0001349000174P60000329CTPNB050064199TPNB050064268
0001349000174P60000329BTPNB050064199TPNB050064268
0001349000174P60000329ATPNB050064199TPNB050064268
AWK script formatted for readability:
BEGIN {
FS=3D"-"
for(i=3D0; i<255; ++i)
asc[sprintf("%c",i)] =3D i
}
/.-./ {
p1=3Dsubstr($1,1,length($1)-1)
p2=3Dsubstr($2,2)
chhi=3Dasc[substr($1,length($1))]
chlo=3Dasc[substr($2,1,1)]
for(; chhi>=3Dchlo; chhi--) {
print p1 sprintf("%c",chhi) p2
}
}
|
|
0
|
|
|
|
Reply
|
shakahshakah (188)
|
7/1/2008 4:34:57 PM
|
|
|
3 Replies
63 Views
(page loaded in 0.083 seconds)
Similiar Articles: Updating numeric values from shell script - comp.unix.shell ...Hello all Have the following problem, can someone please help. I need to do this in a Unix Shell script. I have a text file with the following two l... newbie question: shell script to monitor server performance - comp ...I need a script that to monitor our ... If you need help, hire a consultant ... newbie question: shell script to monitor server performance - comp ..... need a script ... Capturing SP Output In Shell Script - comp.unix.questions ...Greetings, I need to capture the output of a Sybase stored procedure, inside my shell script( k shell). ... Could someone please help. TIA. How can I get a Javascript command to run a Shell script? - comp ...Hi all, I need to get a shell script (on Sun Servers) run from this _javascript code and from ... This is the piece of script I am using: I hope you someone may help me. script for telnet on port 25 - comp.lang.awkI need to do this >> for multiple mail servers with for loop in the shell script. >> Please Help!!! >> Regards > >You can do this in awk to (after all, it's awk's group). AWK command inside the shell script - comp.lang.awkI'm sure you don't need that external > shell loop either but since I ... shell script - comp.lang.awk AWK command help - comp.lang.awk AWK command inside the shell script ... Help: raising x-window on top of a display through HPUX shell ...... through any shell commands or shell script ... Neil To raise the window you need ... top of a display through HPUX shell ... Anyone got LHF Stanford Script? - comp.fonts Help ... Shell Script for mount/umount VXFS - comp.unix.solarisIf you do need a full fsck, umount the filesystem first. ... comp.unix.solaris | Computer ... Guys, Anyone has mount/umount shell Script for VXFS? Please help. ... Unix Shell Scripts and Boolean Expressions - comp.unix.programmer ...Hello, I am new to Unix and shell scripting. I am being ... searching the web but couldnt find much help. Some sites say that when you use boolean expressions you need to ... error while executing ksh script - comp.unix.shellI am kind of new > to shell. Please help > abc[8]: no closing ... has the additional advantage that you don't need ... Test regex in KSH - comp.unix.shell Unix Shell script and ... shell script needs help - LinuxQuestions.orghello, guys. i am new to linux shell script. i have a problem about math scripting. how to write a shell script " 1x1+2x2+3x3+...+100x100= " Shell script - Wikipedia, the free encyclopediaA shell script can be used to ... speed and the need to launch a new process for almost every shell command executed. When a script's job ... Help; About Wikipedia ... 7/30/2012 4:37:55 AM
|