This is not working. It is printing all XML
below two solutions are working.
But I think using initialHeapSize[^0-9]*= could select any text preceding =.
Better way to do it is to say there can be spaces between key and =. There can be zero or more spaces after = and a single or double quote followed by digits.
If I can use above regex in a single sed statement that would even better to understand and maintain.
I think this also is a great solution, if only I could push grep condition into perl regex. This is case insensitive and tries to be precise with key=value matching with best guess for space, =, quotes
Last edited by kchinnam; 02-14-2016 at 12:44 AM..
Reason: corrected text
You could also try this awk script. It can handle single-quoted strings, double-quoted strings, and unquoted strings terminated by a space or ">". It requires an equal-sign (with optional leading and trailing spaces) between keyword and its value. If the value is an empty string, it must be quoted; otherwise the value doesn't need to be quoted unless the value contains a space or ">". Single-quotes can be included in double-quoted strings and double-quotes can be included in single-quoted strings.
Invoke it with the 1st operand being the name of the XML file to be processed, the 2nd operand being the tag on the line to be processed, and the remaining operands being the keywords on that line whose values are to be printed with one output line for each keyword requested printed in the same order as the keywords were given on the command line.
As always, if you want to try this script on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk. (Note that nawk will not correctly process this script.)
If you have a file named file.xml containing:
and you have saved the above script as an executable script named tester, then the command:
produces the output:
and the command:
produces the output:
Last edited by Don Cragun; 02-14-2016 at 03:53 PM..
Reason: Consolidate extraction of quoted string values.
This User Gave Thanks to Don Cragun For This Post:
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi All,
I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file.
comm -3 < sort file_old < sort file_new > new_file
I am getting the below error:
-ksh: sort: cannot open
But if I do... (7 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
I wish to change the parameter (which I do not understand exactly what it is and I wish to) and be able to use shc with very long bash scripts (2 Replies)
Hi, im asking for help with the next script:
echo ^;
then
if
then
printf "\033
query1.sh:
export TERM=vt100
export ORACLE_TERM=at386
export ORACLE_HOME=/home_oracle8i/app/oracle/product/8.1.7
export ORACLE_BASE=/home_oracle8i/app/oracle
export... (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Hi,
We have a Digital Unix Server with OSF.
There's a Kernel Parameter "dflssiz" on this server.
I just want to know, what it means.
Thanks (2 Replies)