08-16-2007
AWK extraction
Hi all,
Can anyone please help me in parsing the following file. Suppose the file is called, example.lst, and has the following content in it.
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(Host = 192.168.2.2)
(Port = 1525)
)
)
(CONNECT_DATA = (SID = TESTDB1)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(Host = 192.168.2.4)
(Port = 1525)
)
)
(CONNECT_DATA = (SID = TESTDB2)
)
)
I want to extract only the value of all Host (i.e, 192.168.2.4, 192.168.2.2) and value of all SID (i.e., TESTDB1, TESTDB2) from this file. Depending on the number of HOST and SID present in the file, i want to assign them to arrays, like
host[1]=192.168.2.2
host[2]=192.168.2.4
sid[1]=TESTDB1
sid[2]=TESTDB2 and so on....
I am trying this script in Korn shell. I am working with AWK.
Any help would be greatly appreciated.
Thanks,
Harris
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi! I'm trying to find a way to extract a certain amount of lines from a log file. This would allow me to "follow" a web user through our log files.
Here is a sample fake log file to explain what i want to accomplish :
BEGIN REQUEST sessionID=123456
boatload of lines for thread-1 detailing... (8 Replies)
Discussion started by: gnagus
8 Replies
2. Shell Programming and Scripting
Hi all,
I have a data file from which i would like to extract only certain fields, which are not adjacent to each other. Following is the format of data file (data.txt) that i have, which has about 6 fields delimited by "|"
HARRIS|23|IT|PROGRAMMER|CHICAGO|EMP
JOHN|35|IT|JAVA|NY|CON... (2 Replies)
Discussion started by: harris2107
2 Replies
3. Shell Programming and Scripting
Hi All,
I need to extract 543 from the command below :
# pvscan
PV /dev/sdb1 VG vg0 lvm2
Total: 1 543.88 GB] / in use: 1 / in no VG: 0
I have the following command which does the job, but I think this could be achieved in a more simple way using sed or awk. Any help is... (7 Replies)
Discussion started by: nua7
7 Replies
4. Shell Programming and Scripting
Hi,
I am trying to extract the first and last lines for each unique item in column 2 of a large text file and then concatenate all extracted lines together in a new text file.
So ... I want to go from this format:
NEW 0088-BPM 1.042700e+04 877168.19 9718360.00 1496.00
NEW 0088-BPM... (5 Replies)
Discussion started by: jazthedribbler
5 Replies
5. Shell Programming and Scripting
Hello everybody,
Here is my problem : I cannot find a way to extract data from a particular file and more precisely I cannot extract the result of my awk script to an external file because I am currently working on HP-UX.
I would like a simple script (without awk) which asks for a date like... (4 Replies)
Discussion started by: freyr
4 Replies
6. Shell Programming and Scripting
Hello
does anyone know of an awk that will extract log file entries between a specific date and time range, eg:
awk '/15\/Dec\/2010:16:10:00/, /15\/Dec\/2010:16:15:00/' access_log
but one that works?
Or a free command line log file analysis tool/script?
I'd like to be able to view... (2 Replies)
Discussion started by: competitions
2 Replies
7. Shell Programming and Scripting
I have following input
@xxxxxx@
I want to extract what's between @....@ that is : xxxx
using SED command (6 Replies)
Discussion started by: xerox
6 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I have a file like this-
aa
12
23
34
aa
21
34
56
aa
78
45
56
I want to print out only the lines after the last aa. How do I do this? I tried using grep -A and sed -n, but both didnt work as I wanted to.
Could someone help me out please.. (3 Replies)
Discussion started by: jamie_123
3 Replies
9. Shell Programming and Scripting
Hi,
I need some help in getting extracting the specific horizontal and vertical texts in a single line. I am trying to extract few of the parameters from a config file. Your help is appreciated.
Desired Output
----------------
Pool members members ... (4 Replies)
Discussion started by: pratheeshp
4 Replies
10. Shell Programming and Scripting
fitted parameters initialized with current variable values (0 Replies)
Discussion started by: kayak
0 Replies
IGAWK(1) Utility Commands IGAWK(1)
NAME
igawk - gawk with include files
SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ...
igawk [ all gawk options ] [ -- ] program-text file ...
DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1).
AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like
@include getopt.awk
in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path.
OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports.
EXAMPLES
cat << EOF > test.awk
@include getopt.awk
BEGIN {
while (getopt(ARGC, ARGV, "am:q") != -1)
...
}
EOF
igawk -f test.awk
SEE ALSO
gawk(1)
Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995.
AUTHOR
Arnold Robbins (arnold@skeeve.com).
Free Software Foundation Nov 3 1999 IGAWK(1)