help in writing awk script, plz urgent


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help in writing awk script, plz urgent
# 1  
Old 06-27-2007
help in writing awk script, plz urgent

I have a file like this I have to
I have input file this , I want to give the out put in the below

input file
(NARAYANA 1 ENDING AT (100, 16383)
,NARAYANA 2 ENDING AT (100, 32766)
,NARAYANA 3 ENDING AT (100, 49149)
,NARAYANA 4 ENDING AT (100, 65535)
,NARAYANA 5 ENDING AT (200, 16383)
,NARAYANA 6 ENDING AT (200, 32766)
,NARAYANA 7 ENDING AT (200, 49149)
,NARAYANA 8 ENDING AT (200, 65535))

----------------------------------------------------

output file:

(NARAYANA 1 ENDING AT(100, 8191)
,NARAYANA 1 ENDING AT(100, 16383)
,NARAYANA 2 ENDING AT(100, 24574)
,NARAYANA 2 ENDING AT(100, 32766)
,NARAYANA 3 ENDING AT(100, 40957)
,NARAYANA 3 ENDING AT(100, 49149)
,NARAYANA 4 ENDING AT(100, 57342)
,NARAYANA 4 ENDING AT(100, 65535)
,NARAYANA 5 ENDING AT(200, 8191)
,NARAYANA 5 ENDING AT(200, 16383)
,NARAYANA 6 ENDING AT(200, 24574)
,NARAYANA 6 ENDING AT(200, 32766)
,NARAYANA 7 ENDING AT(200, 40957)
,NARAYANA 7 ENDING AT(200, 49149)
,NARAYANA 8 ENDING AT(200, 57342)
,NARAYANA 8 ENDING AT(200, 65535) )
# 2  
Old 06-27-2007
help in writing awk script, plz urgent

I have a file like this I have to
I have input file this , I want to give the out put in the below

input file
(NARAYANA 1 ENDING AT (100, 16383)
,NARAYANA 2 ENDING AT (100, 32766)
,NARAYANA 3 ENDING AT (100, 49149)
,NARAYANA 4 ENDING AT (100, 65535)
,NARAYANA 5 ENDING AT (200, 16383)
,NARAYANA 6 ENDING AT (200, 32766)
,NARAYANA 7 ENDING AT (200, 49149)
,NARAYANA 8 ENDING AT (200, 65535))

----------------------------------------------------

output file:

(NARAYANA 1 ENDING AT(100, 8191)
,NARAYANA 2 ENDING AT(100, 16383)
,NARAYANA 3 ENDING AT(100, 24574)
,NARAYANA 4 ENDING AT(100, 32766)
,NARAYANA 5 ENDING AT(100, 40957)
,NARAYANA 6 ENDING AT(100, 49149)
,NARAYANA 7 ENDING AT(100, 57342)
,NARAYANA 8 ENDING AT(100, 65535)
,NARAYANA 9 ENDING AT(200, 8191)
,NARAYANA 10 ENDING AT(200, 16383)
,NARAYANA 11 ENDING AT(200, 24574)
,NARAYANA 12 ENDING AT(200, 32766)
,NARAYANA 13 ENDING AT(200, 40957)
,NARAYANA 14 ENDING AT(200, 49149)
,NARAYANA 15 ENDING AT(200, 57342)
,NARAYANA 16 ENDING AT(200, 65535) )
# 3  
Old 06-27-2007
Hi,
I dont think there is enough clarity on this question. What are you trying to solve?

Thanks
Nagarajan G
# 4  
Old 06-27-2007
Code:
awk ' BEGIN { n=1;a[1]=8191; a[2]=24574;a[3]=40957;a[0]=57342 }
NR == 1 { sub("^.",""); printf("(") }
{ $2=n+1; NR == 1 ? tmp=","$0 : tmp=$0; $NF=a[n%4]")"; $2=n; n=n+2; $0=$0"\n"tmp }1 ' filename

# 5  
Old 06-27-2007
hey i am not getting this

awk '{if($0 ~ / ENDING /) printf("%s\n%s\n",$0,$0); else print $0;}' filename \

| awk -f interesting.awk



interesting.awk

BEGIN{i=0; flag=1; tag="" ;num=0;}

{if($0 ~ / ENDING /)

{ if(tag != $6)

{ num=0;

tag=$6;

}

++i;

if (flag == 1)

{ printf("%s %s %s %s %s %s %s) %s %s%d\n",$1,$2,$3,$4,$5,int((substr($6,1,length($6)-1)+num)/2),i);

flag = 0;

num=substr($6,1,length($6)-1);

}

else

{ printf("%s %s %s %s %s %s%d\n",$1,$2,$3,$4,$5,$6,$7,$8,substr($9,1,5),i);

flag = 1;

}

}

else print $0;



I HAVE TRIED LIKE THIS , BUT SOME WHERE THE PROBLEM IS OCCURRING
PLZ HELP IN THIS URGENTLY

}
# 6  
Old 06-27-2007
Why do you let us guess what you want to do ? Input and Output samples aren't sufficient.

Try the follwing script :
Code:
awk '
   $3 == "ENDING" {
      seq = $2;
      val = int($6);
      print $1, seq*2-1, $3, $4, $5, val-8192 ")";
      sub(/^\(/, ",");
      print $1, seq*2,   $3, $4, $5, val (/))$/ ? "))" : ")");
   }
' filename

Quote:
Originally Posted by LAKSHMI NARAYAN
I HAVE TRIED LIKE THIS , BUT SOME WHERE THE PROBLEM IS OCCURRING
PLZ HELP IN THIS URGENTLY
Don't cry !
Il est souvent urgent de ne pas se presser.
# 7  
Old 06-27-2007
awk

Pls try follow, hope can help you:

Code:
awk 'BEGIN{f="8191" s="24574" t="40957" fo="57342"}
NR==1{
match($0,",") print substr($0,1,RSTART) f ")"print substr($0,2)
}
NR==2{match($0,$4)print substr($0,1,RSTART+7) s ")"print $0
}
NR==3{match($0,$4)    print substr($0,1,RSTART+7) t ")"print $0
}
NR==4{match($0,$4)    print substr($0,1,RSTART+7) fo ")"print $0}
....
' filename

And i do not know why the first line is work ok as above, but the other lines do not work as the same method in line one,
so i try to realize it in a different way.

You can try on follow my idea. If you get better,pls post it out so that all of us can share your ideas. Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Need help..Urgent plz

Hi All, For listing large files i am using the following command find /XYZ/ -xdev -size +100000 |xargs ls -l |sort -nr -k 5..And my question is i am getting more number of files with this, so not able to copy those, how can I get those all in page by page , so that I can able to copy those... (4 Replies)
Discussion started by: adminaix55
4 Replies

2. Shell Programming and Scripting

error in shell script while returning values-- urgent issue plz help.

Hi, I have initailized a varaible EBID as typeset Long EBID=0 i am calculating value of EBID using certian formula as below: (( CURR_EBID= ($BANDINDEX << 27) | ($CURR_FREQ << 16) | ($CURR_CELLID << 4) | $CURR_SECTOR_VALUE )) return $CURR_EBID The output is as below: + (( CURR_EBID=... (6 Replies)
Discussion started by: kasanur
6 Replies

3. Shell Programming and Scripting

Clarify doubt ... plz Urgent

Hi friends, I am new to UNIX. I going to transfer files using SFTP. I am writing a script and using mget . If i am using mget * means, if all the files and their sub directories are transferred or not? If suppose , the local system dose not have the sub directory then what will... (1 Reply)
Discussion started by: punitha
1 Replies

4. Shell Programming and Scripting

Explain this AWK script plz

Hi frnds, one my frnds has given resolution for my problem as below. it working great , but i couldnt understand somethings in the script. Why ++ operator after the function calling. how these each block working. will each run for each input line sequencially or one block for all the lines... (9 Replies)
Discussion started by: Gopal_Engg
9 Replies

5. UNIX for Dummies Questions & Answers

plz help me urgent....

i want shell script program for counting the no of times the given input word is occured in the given input file.i am unable to do this .i got some of output with awk but i need it completely with shell script program i am waiting for the solution (4 Replies)
Discussion started by: sankar_1209
4 Replies

6. Solaris

plz help me in writing a script

Hi all, I want to write a script which gather all files who where having a particular name.The script should run at the end of each month. The files(Audit and health files) are generated each day. I want to gather the files seperately into corresponding folders and so that i can ftp'ed... (3 Replies)
Discussion started by: Renjesh
3 Replies

7. Shell Programming and Scripting

plz help in writing awk script

hi buddies pls help in this matter i have file like this input file -------------------------- (PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1 ,PARTITION PARTITION_2 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_2 ,PARTITION PARTITION_3 VALUES LESS THAN (101,... (3 Replies)
Discussion started by: LAKSHMI NARAYAN
3 Replies

8. Shell Programming and Scripting

plz solve this one : URGENT

Hi! How to use awk command and set command in a shell script? Suppose I have to fetch data from a file and change one data with another one.Say data is ABCD.Now I have to change C with X .How do I solve this one? (2 Replies)
Discussion started by: joyita bagchi
2 Replies

9. UNIX for Dummies Questions & Answers

find command - Urgent Plz.

Hi, In my current directory, i have the following files: x1.dat x2.dat.gz x3.dat I want to use the find command and display only files which has *.dat and NOT *.gz extension files. Please help me out. Thanks, Kris Kart. (2 Replies)
Discussion started by: Kris_Kart_101
2 Replies

10. UNIX for Dummies Questions & Answers

urgent plz

guys i have sun solaries 8 under intel .. i added a new D-LINK ethernet and i need to see if the computer define it or not .. so i need to make reconfiguraion .. what was the command ... for reconfiguration ??? thanks alot (3 Replies)
Discussion started by: tamemi
3 Replies
Login or Register to Ask a Question