awk not working for me.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk not working for me.
# 1  
Old 07-11-2008
awk not working for me.

Hi All,
I have a server.xml file which looks something like.

Code:
 <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="./webapps/WebLM/WEB-INF/weblmserver.p12"
               keystoreType="PKCS12" keystorePass="password" />
 
<!-- The Dist Cert default cert -->
    <Connector port="28444" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="true" sslProtocol="SSL"
               keystoreFile="/opt/coreservices/avaya/certs/pfxs/Avaya_Common.pfx"
               keystorePass="abcpass" keystoreType="PKCS12"
               truststoreFile="/opt/coreservices/abc/certs/jks/trustedcerts.jks"
               truststorePass="password" truststoreType="JKS" /

I need to extract the value after keystorePass. I tried the following command ,but it gives me only "password as a output. It should also give me "abcpass"

Code:
awk -F"\"" '$3 ~ "keystorePass="{print $4}' server.xml

Output:
Code:
[root@catinfo conf]# awk -F"\"" '$3 ~ "keystorePass="{print $4}' server.xml
password

Can anyone please help!
# 2  
Old 07-11-2008
Should be easier with perl:

Code:
perl -lne'print $1 if /keystorePass="(.*?)"/' server.xml

# 3  
Old 07-11-2008
wow! It worked!

wow! it worked..!! Thanks a lot!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: System command not working in awk

Hi, I have around 10 files in a folder in which I want to change the file format from tab(\t) to pipe(|) with some changes in the fields as well. Below is the code, while tmp file is getting generated but move command is not working, please help Following is the code awk -F"\t" '{print... (2 Replies)
Discussion started by: siramitsharma
2 Replies

2. Shell Programming and Scripting

awk - why this is not working? trying next word!

Hi Experts, Can you please advise , why I am not able to make it work, or why this is not working: I spent quite a lot of time on this figuring out , but not working, file : This is a test file thanks for your reply This is another file again Have a nice day this is a small file... (3 Replies)
Discussion started by: rveri
3 Replies

3. Shell Programming and Scripting

awk help : if then else not working!

Hi All, This code is not working when trying with "else" : Am I missing something, uptime|sed 's/,/ /g' | awk '{ if ($10 >1) { print ( " :: UPTIME GT 1 : ALERT" )} ;else print "OK" }' Getting this error: syntax error The source line is 1. The error context is { if... (4 Replies)
Discussion started by: rveri
4 Replies

4. Shell Programming and Scripting

awk not working correctly

Hi I am attempting to right a script which will read a table and extract specfic information. LASTFAILEDJOB=/usr/openv/netbackup/scripts/GB-LDN/Junaid/temp_files/lastfailedjob cat /usr/openv/netbackup/scripts/GB-LDN/Junaid/temp_files/lastfailedjob 237308646 If i run the following... (5 Replies)
Discussion started by: Junes
5 Replies

5. Shell Programming and Scripting

awk isn't working

awk 'BEGIN{print '1.2449'**0.5}' awk: line 1: syntax error at or near * can someone help me troubleshoot the above command? i'm trying to do the square root of 1.2449. this command works on Red Hat, but for some reasonn isn't working on kubuntu (latest version). shell is bash. i... (3 Replies)
Discussion started by: SkySmart
3 Replies

6. Shell Programming and Scripting

[awk] working with two files

Hello guys, I have little to no experience working with two files in awk and hope you can help me with a problem that may be easy for you to solve... awk -v cut1="$var1" -v cut2="$var2" '{split($0, arr1); for(i=1;i<=NF;i++) if (arr1 < cut1) print arr1, NR, i}' file1 file2 The above code is... (4 Replies)
Discussion started by: origamisven
4 Replies

7. UNIX for Advanced & Expert Users

Awk expressions working & not working

Hi, Putting across a few awk expressions. Apart from the last, all of them are working. echo a/b/c | awk -F'/b/c$' '{print $1}' a echo a/b/c++ | awk -F'/b/c++' '{print $1}' a echo a/b/c++ | awk -F'/b/c++$' '{print $1}' a/b/c++ Request thoughts on why putting a '$' post double ++... (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies

8. Shell Programming and Scripting

awk command not working

Hi all, Trying to write a script that reads a file and prints everything after a certain string is found to the end of the file. Awk is giving me an error and not sure why it doesn't work: # cat test_file Mon Nov 16 2009 16:11:08 abc def Tue Nov 17 2009 16:08:06 ghi jkl Wed Nov 18... (8 Replies)
Discussion started by: jamie_collins
8 Replies

9. UNIX for Dummies Questions & Answers

Logical AND, OR not working with awk.

awk -F^ '{ if ((($1 == "M") && ($5 == "2")) || (($1 == "S") && ($5 == "7"))) print $0}' welcome > welcome1 When I run the above awk command, I could see the same content of welcome in welcome1. Later, I found that the logicals "&&", "||" used in the above command is not working. Can any... (2 Replies)
Discussion started by: karthickrn
2 Replies

10. Shell Programming and Scripting

awk not working in script

Hi All, i'm trying awk commnad to read only file names with the help of below command :- ls -l tmp*.txt | awk { 'print $9' } | head -1 The command is working fine :o on command line, but when i trying it in script then its not working $var1=`ls -l tmp*.txt | awk { 'print $9' } | head -1`... (3 Replies)
Discussion started by: doitnow
3 Replies
Login or Register to Ask a Question