plz help in writing awk script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting plz help in writing awk script
# 1  
Old 07-13-2007
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, 49149 ) TABLESPACE PART_3
,PARTITION PARTITION_4 VALUES LESS THAN (101, 65535 ) TABLESPACE PART_4
,PARTITION PARTITION_3 VALUES LESS THAN (101, 49149 ) TABLESPACE PART_3
,PARTITION PARTITION_4 VALUES LESS THAN (101, 65535 ) TABLESPACE PART_4
,PARTITION PARTITION_5 VALUES LESS THAN (102, 16383 ) TABLESPACE PART_5
,PARTITION PARTITION_6 VALUES LESS THAN (102, 32766 ) TABLESPACE PART_6
,PARTITION PARTITION_7 VALUES LESS THAN (102, 49149 ) TABLESPACE PART_7
,PARTITION PARTITION_8 VALUES LESS THAN (102, 65535 ) TABLESPACE PART_8 ) ;

i need out file like this:
---------------------
(PARTITION PARTITION_1 VALUES LESS THAN (101, 4095 ) TABLESPACE PART_1
,PARTITION PARTITION_2 VALUES LESS THAN (101, 8191 ) TABLESPACE PART_2
,PARTITION PARTITION_3 VALUES LESS THAN (101, 12287 ) TABLESPACE PART_3
,PARTITION PARTITION_4 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_4
,PARTITION PARTITION_5 VALUES LESS THAN (101, 20478 ) TABLESPACE PART_5
,PARTITION PARTITION_6 VALUES LESS THAN (101, 24574 ) TABLESPACE PART_6
,PARTITION PARTITION_7 VALUES LESS THAN (101, 28670 ) TABLESPACE PART_7
,PARTITION PARTITION_8 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_8
,PARTITION PARTITION_9 VALUES LESS THAN (101, 36861 ) TABLESPACE PART_9
,PARTITION PARTITION_10 VALUES LESS THAN (101, 40957 ) TABLESPACE PART_10
,PARTITION PARTITION_11 VALUES LESS THAN (101, 45053 ) TABLESPACE PART_11
,PARTITION PARTITION_12 VALUES LESS THAN (101, 49149 ) TABLESPACE PART_12
,PARTITION PARTITION_13 VALUES LESS THAN (101, 53245 ) TABLESPACE PART_13
,PARTITION PARTITION_14 VALUES LESS THAN (101, 57342 ) TABLESPACE PART_14
,PARTITION PARTITION_15 VALUES LESS THAN (101, 61438 ) TABLESPACE PART_15
,PARTITION PARTITION_16 VALUES LESS THAN (101, 65535 ) TABLESPACE PART_16
,PARTITION PARTITION_17 VALUES LESS THAN (102, 4095 ) TABLESPACE PART_17
,PARTITION PARTITION_18 VALUES LESS THAN (102, 8191 ) TABLESPACE PART_18
,PARTITION PARTITION_19 VALUES LESS THAN (102, 12287 ) TABLESPACE PART_19
,PARTITION PARTITION_20 VALUES LESS THAN (102, 16383 ) TABLESPACE PART_20
,PARTITION PARTITION_21 VALUES LESS THAN (102, 20478 ) TABLESPACE PART_21
,PARTITION PARTITION_22 VALUES LESS THAN (102, 24574 ) TABLESPACE PART_22
,PARTITION PARTITION_23 VALUES LESS THAN (102, 28670 ) TABLESPACE PART_23
,PARTITION PARTITION_24 VALUES LESS THAN (102, 32766 ) TABLESPACE PART_24;
# 2  
Old 07-13-2007
I see a pattern from PARTITION_1 to PARTITION_16.

The thing I dont get is what decides the jump from 101,65535 to 102,4095 in these lines
Code:
,PARTITION PARTITION_16 VALUES LESS THAN (101, 65535 ) TABLESPACE PART_16
,PARTITION PARTITION_17 VALUES LESS THAN (102, 4095 ) TABLESPACE PART_17

# 3  
Old 07-13-2007
If I understand your code correctly, it is adding 4096, but your
example is not being consistent:
Code:
,PARTITION PARTITION_4 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_4
,PARTITION PARTITION_5 VALUES LESS THAN (101, 20478 ) TABLESPACE PART_5

It should be:
Code:
,PARTITION PARTITION_4 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_4
,PARTITION PARTITION_5 VALUES LESS THAN (101, 20479 ) TABLESPACE PART_5

Other numbers should be changed too.

In any event, see if this works for you:
Code:
typeset -i mCnt1=1
typeset -i mCnt2=4095
mVar='101'
while [ $mCnt1 -le 24 ]
do
 if [ $mCnt1 -eq 17 ]; then
   mVar='102'
   mCnt2=4095
 fi
 mPart1='PARTITION PARTITION_'${mCnt1}' VALUES LESS THAN ('${mVar}
 mPart2=', '${mCnt2}' ) TABLESPACE PART_'${mCnt1}
 echo ${mPart1}${mPart2}
 mCnt1=${mCnt1}+1
 mCnt2=${mCnt2}+4096
done

# 4  
Old 07-14-2007
Quote:
(PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1

For each of the partition values 'partition_1' is this a sub split in the multiple of 4 K ( 4 x 1024 ) with minumnum being 4K and maximum being 65 K
and once it reaches 65k with first argument 101, its moving on with the same pattern to the next value of 101 (i.e.) 102.

Is that the right pattern ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help with writing a awk/sed script

Hi, I thought I am getting pretty good with sed and awk, but now I dont have a way out of this question. I have a table 0.5 16 1.3 14 0.25 15 0.85 16 I want to make a column 3 which contains values that are (corresponding $2 value/sum of all $2). Please help me out here. Thanks. (6 Replies)
Discussion started by: jamie_123
6 Replies

2. UNIX for Dummies Questions & Answers

awk: issues for writing a script

%%%%% (7 Replies)
Discussion started by: lucasvs
7 Replies

3. UNIX for Dummies Questions & Answers

Writing awk script to read csv files and split them

Hi Here is my script that calls my awk script #!/bin/bash set -x dir="/var/local/dsx/csv" testfile="$testfile" while getopts " f: " option do case $option in f ) testfile="$OPTARG";; esac; done ./scriptFile --testfile=$testfile >> $dir/$testfile.csv It calls my awk... (1 Reply)
Discussion started by: ladyAnne
1 Replies

4. Shell Programming and Scripting

Help in writing a find/replace script using awk

Hi All, I need to write a script that will go through 600+ files and perform find and replace. I was going to use sed but there is a level of complexity that is doing my head in. To explain: I have 600+ files that have a line in them that reads (for example) FILE=DCLCLHST... (4 Replies)
Discussion started by: Kocko
4 Replies

5. 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

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

Help needed in writing awk script for xml source

Hi, i am not able to get an approach for converting xml file to flat file using awk programming. Can anyone help me out. The input xml is like this: <outer> <field1>one</field1> <field2>two</field2> <field3>three<Error Code=777 Description=12345/></field3> <field4>four</field4> </outer>... (2 Replies)
Discussion started by: naren_0101bits
2 Replies

8. Shell Programming and Scripting

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... (8 Replies)
Discussion started by: LAKSHMI NARAYAN
8 Replies

9. Shell Programming and Scripting

hi help in writing awk script(urgently)

hi to all i have file like this file.txt this is naryana expect hyderabad is a cool place now climate VISAKHSAPATNAM became very cool #vizag is my birth place #hyderabad is a cool place #now climate of hyd became very cool #vizag is my birth place #hyderabad is a cool place ... (7 Replies)
Discussion started by: LAKSHMI NARAYAN
7 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question