Need help in a script to filter specific pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in a script to filter specific pattern
# 1  
Old 02-06-2014
Need help in a script to filter specific pattern

Hello ,

Below is the command

Code:
srvctl config database -d cmdbut -s boms10.world

Below is the output. Now in the command instead of cmdbut it will be a variable like $database which would be called in the script as below:

Code:
srvctl config database -d $database -s $service

Now,as shown in output for one database cmdbut there is a service boms10.world which is underlined and for this service there is one preferred and one available instance.Now I need this preferred and variable instance to be stored in 2 variables.
Please assist.
one variable should have cmdbut_01 and the other variable should have cmdbut_02.
Code:
Service name: boms10.world
Service is enabled
Server pool: cmdbut_boms10.world
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Edition:
Preferred instances: cmdbut_01
Available instances: cmdbut_02



Best regards,
Vishal
# 2  
Old 02-06-2014
Giving Your OS and version and your default shell can help you know...
# 3  
Old 02-06-2014
AIX 6.1 is the os



Best regards,
Vishal
# 4  
Old 02-06-2014
Does
Code:
srvctl config database -d cmdbut -s boms10.world | tail -2|awk ' { print $3}'

give you your variables?

Last edited by vbe; 02-06-2014 at 01:52 PM.. Reason: typo...
# 5  
Old 02-06-2014
So - are you looking for "instances" or for "cmdbut"?
# 6  
Old 02-07-2014
I am looking for preferred and available instances.



Best regards,
Vishal
# 7  
Old 02-09-2014
OK, the least sophisticated ansatz would be
Code:
var01=$(srvctl config database -d $database -s $service | awk '/^Preferred instance/ {print $3}'
var02=$(srvctl config database -d $database -s $service | awk '/^Available instance/ {print $3}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract whole word preceding a specific character pattern with first occurence of the pattern

Hello. Here is a file contents : declare -Ax NEW_FORCE_IGNORE_ARRAY=(="§" ="§" ="§" ="§" ="§" .................. ="§"Here is a pattern =I want to extract 'NEW_FORCE_IGNORE_ARRAY' which is the whole word before the first occurrence of pattern '=' Is there a better solution than mine :... (3 Replies)
Discussion started by: jcdole
3 Replies

2. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

I have files in a Linux directory . Some of the file is listed below -rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Discussion started by: Balraj
4 Replies

3. Shell Programming and Scripting

Filter pattern in grep command

Hi, I am having a file like below hello how are you hello... (5 Replies)
Discussion started by: rohit_shinez
5 Replies

4. Shell Programming and Scripting

how to filter file for specific date

Hi My OS is solaris 64 bit 10, I have many files in a logs directory where we recive 40-50 logs every day. i have last 20 days file present in this directory. I want to move each day file to a particulaar directory whose name is appended with the date of file. eg Code: 1.txt file... (1 Reply)
Discussion started by: guddu_12
1 Replies

5. UNIX for Dummies Questions & Answers

How to Detect Specific Pattern and Print the Specific String after It?

I'm still beginner and maybe someone can help me. I have this input: the great warrior a, b, c and what i want to know is, with awk, how can i detect the string with 'warrior' string on it and print the a, b, and c seperately, become like this : Warrior Type a b c Im still very... (3 Replies)
Discussion started by: radynaraya
3 Replies

6. UNIX for Dummies Questions & Answers

Filter file according to pattern

Hello I have an input file which is tab delimited.In my unix script I have search for a particular pattern.If it is NOT present then I have to write in an output file. Eg.Input file is : 123 hello 7779 hi hkjh88 hahah 678 hello 90845 ti hkjsdfh 9324 And the search string is "123... (2 Replies)
Discussion started by: akashtcs
2 Replies

7. Shell Programming and Scripting

To filter a certain pattern depending on neighbour

Hi, As I am new to filtering section of Unix I am facing a problem I have following lines in text file : Created RELEASE in dist/Apple_release_1_0_.zip Created RELEASE in dist/Banana_release_1_0_.zip Created RELEASE in dist/Mango_release_1_0_.zip Created RELEASE in... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

8. UNIX for Dummies Questions & Answers

how do I filter for a specific line in a file?

It seems like it should be very simple to have a command like grep return a specific line from a file but I can't find anything in the man pages to make grep search by line. I've looked in cat as well. Anyone know how to return a single line from a file? (5 Replies)
Discussion started by: gelitini
5 Replies

9. HP-UX

extract field of characters after a specific pattern - using UNIX shell script

Hello, Below is my input file's content ( in HP-UX platform ): ABCD120672-B21 1 ABCD142257-002 1 ABCD142257-003 1 ABCD142257-006 1 From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could... (2 Replies)
Discussion started by: jansat
2 Replies

10. Shell Programming and Scripting

need help--script to filter specific lines from multiple txt files

Hi folks, - I have 800 txt files - those files are cisco router configs router1.txt router2.txt ... router800.txt I want to accomplish the following: - I want to have a seperate file with all the filenames that I want to process - I want a script that goes trough all those... (7 Replies)
Discussion started by: I-1
7 Replies
Login or Register to Ask a Question