Fetch the different data by searching with a same variable from a file in AIX server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetch the different data by searching with a same variable from a file in AIX server
# 1  
Old 07-05-2012
Fetch the different data by searching with a same variable from a file in AIX server

Hi,

I am trying to fetch the different values in an xml file by searching with the same variable in AIX Server.

Code:
            <name>SharedResources/Shared/JNDI/Username</name>
            <value>admin</value>                    <name>SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>                    <name>SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>                    <name>SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>                    <name>SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>           <name>SharedResources/Shared/JNDI/Password</name>
            <value>admin123</value>                   <name>SharedResources/Shared/JNDI/Password</name>
                <value>#!kj9VGDvpH5UxAqjjpV4AgXxZfvl</value>                  <name>SharedResources/Shared/JNDI/Password</name>
                    <value>#!ngLHtJvuLh1zZu2JPlG2IMw393zcO</value>
                   
<name>SharedResources/Shared/JNDI/Password</name>
                    <value>#!miE1fyQpqpxGnyFFAYSCvFfyBH</value>
                   
<name>SharedResources/Shared/JNDI/Password</name>
                    <value>#!0zhAipKWDFPiz48XAL+5zUVHu</value>


From the above file, i am searching with variable
"SharedResources/Shared/JNDI/Password"

Code:
nawk -v l="SharedResources/Shared/JNDI/Password" '$0~l{getline;print;exit}' secure.xml

but its displaying only one value. i.e., <value>admin123</value>

it's not displaying the remaining values.

Please help me out from this.

---------- Post updated at 02:20 AM ---------- Previous update was at 02:17 AM ----------

sorry the values displayed wrongly

Code:
            <name>Security/SharedResources/Shared/JNDI/Username</name>
            <value>admin</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Username</name>
                    <value>tibbw</value>
            <name>Security/SharedResources/Shared/JNDI/Password</name>
            <value>admin123</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Password</name>
                    <value>#!kj9VGDvpH5UVqjjpV4AgXxZfvl</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Password</name>
                    <value>#!ngLHtJvuLhTMX1JPlG2IMw393zcO</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Password</name>
                    <value>#!miE1fyQpqpxnyFFAYSCvFfyBH</value>
--
                    <name>Security/SharedResources/Shared/JNDI/Password</name>
                    <value>#!0zhAipKWDF1iz48XAL+5zUVHu</value>

Please find the above values presented in secure.xml file

Last edited by Scrutinizer; 07-05-2012 at 04:33 AM.. Reason: code tags
# 2  
Old 07-05-2012
Hi


Code:
$ awk '/SharedResources\/Shared\/JNDI\/Password/{getline;print;}' file
<value>admin123</value>
<value>#!kj9VGDvpH5UVqjjpV4AgXxZfvl</value>
<value>#!ngLHtJvuLhTMX1JPlG2IMw393zcO</value>
<value>#!miE1fyQpqpxnyFFAYSCvFfyBH</value>
<value>#!0zhAipKWDF1iz48XAL+5zUVHu</value>

Guru.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fetch data from file

Hi, I am new to scripting. I have a log file and need to fetch specific logs and copy to another file. A copy of the log is like this: =============================================================== = JOB : server123#jobs1.jobstream1 = USER : andyc = Tue 08/01/17... (3 Replies)
Discussion started by: Prngp
3 Replies

2. UNIX for Beginners Questions & Answers

How to fetch specific data from a file.?

Hi , I have a file which contains 2 days logs(here it is 24 and 25) I want to list data only for date 25 fron the file. please suggest me how should i get this. file content mentioned below 17-05-24 Name Succ Fail 00:00:29 ... (5 Replies)
Discussion started by: scriptor
5 Replies

3. Shell Programming and Scripting

Fetch Data from File using UNIX or Perl

Hello, How All are Doing today. I have a issue, I have a file which contains the data as follow <ENVELOPE><ENVELOPE_ID>TEST</ENVELOPE_ID><ENVELOPE_EXTERNAL_ID></ENVELOPE_EXTERNAL_ID><ENVELOPE_VERSION>2</ENVELOPE_VERSION><SIResourceDefaultVersion>true</SIResourceDefaultVersion><TYPE>GS... (1 Reply)
Discussion started by: adisky123
1 Replies

4. Shell Programming and Scripting

Fetch data between two dates from a file

Hi All, I m new to this forum & UNix too. currently i have a requirement which can fetch data from a logfile between two dates or timestamp. for example: 1. data from 2012 Jun to 2012 Jul 2. data from 2012 Jun to 2012 Jul 07 3. data from 2012 Jun 16 10:20 to 2012 Jul 03 10:10 Please... (7 Replies)
Discussion started by: KDMishra
7 Replies

5. Shell Programming and Scripting

How to print the next line by searching with different patterns in AIX server?

Hi, I am having an '.xml' file with 'n' number of lines and also having another file with '.txt' format contains values which i want to search. Now I want to print the next line with the pattern which i am searching in '.xml' file. And the loop has to repeat for different patterns which are... (4 Replies)
Discussion started by: tejastrikez
4 Replies

6. Shell Programming and Scripting

How to fetch data between two timestamps in a file using KSH

Hi, I got a requirement to fetch data between two time stamps in a big log file and grep for a word in that particular time interval of data. Here is my log looks like: 2012/04/08-14:35:56 Abcdefg 2012/04/08-14:35:56 Hijklmnophhoishfw 2012/04/08-14:35:56... (1 Reply)
Discussion started by: siri_886
1 Replies

7. Shell Programming and Scripting

How to fetch File from a URL to Unix Server?

Hello All, I wanted to get the software to be fetched from the Service Provide URL to my unix server. I tired using the mget, but resulted in error. Please take a look. $ wget -O V3-0-5-2.Solaris8-SPARC.tar.gz --http-user=hd87es3 --http-passwd=987dnja7 http://beyond.abinitio.com... (3 Replies)
Discussion started by: raghunsi
3 Replies

8. Shell Programming and Scripting

To Fetch a File From FTP server

Hi all, I need to download a file from ftp server through application server(UNIX server). Which only has sufficient privileges to connect to ftp server. And from that server( app server) i have to get that downloaded file in to my current UNIX server(working server where i am working). we... (5 Replies)
Discussion started by: dvk121
5 Replies

9. Shell Programming and Scripting

How to sca a sequential file and fetch some substring data from it

Hi, I have a task where i need to scan second column of seuential file and fetch first 3 digits of that column For e.g. FOLLOWING IS THE SAMPLE FOR MY SEQUENTIAL FILE AU_ID ACCT_NUM CRNCY_CDE THHSBC001 30045678 THB THHSBC001 10154267 THB THHSBC001 ... (2 Replies)
Discussion started by: manmeet
2 Replies

10. Shell Programming and Scripting

How to fetch data from a text file in Unix

I want to fetch passwords from a common file xxxx.txt and use it in a script. Currently the password is hardcoded so this have to be changed so that password can be fetched from text file..... Please reply asap.. Thanks (4 Replies)
Discussion started by: shikhakaul
4 Replies
Login or Register to Ask a Question