I have written a script to parse data from some files on a Solaris 10 system and send the output to a CSV formatted file. The code snipped i am using to pull the data is as follows....
I use SED to find the pattern in the file and report back with a line number.
It is possible that there can be more than one match in a file and all matches must be processed. After the match is found i skip n line, 9 in this case. If the vaule of filed 2 is numeric then Fileds 2,4,6....n are printed, If not then i know i have reached the end of the table which i am pulling data from.
I am trying to find a soulution to use AWK entirely for the process above but so far i have had no luck.
I can get AWK to find the pattern match, but i am unable to get it to skip the 9 lines.
Below is a sample from of data from a file i am processing
PS daa should look like this when opens in a plain txt editor.
Regards
Denis.
Last edited by electricheadx; 12-06-2013 at 06:49 AM..
What's your search pattern? Without knowing that it's quite difficult to interpret the awk script's behaviour.
Assuming the pattern you search for be ++++..., this will print the desired fields from your input sample:
It will NOT scan for further occurrences of the pattern, but this could easily be implemented
Sorry for the delayed response.
The search pattern will always be the section "Table Header".
An example of header would be "Output Offset 1". The target file i am scanning is made up of 100's of instances of such tables all with different headers.
The number of occurences of rows listed in the table will range from 1 to N.
I will never know beforehand the number of rows, so this is why i have always checked to see if field 2 is numeric or not. If its not numeric i know i have reached the end of the table.
'Hi
I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match.
Which option is to be used to exclude the line containing the pattern?
sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Dear Unix Forums,
I am hoping you can help me with a pattern matching problem.
What am I trying to do?
I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
hi All,
i want to add the single digit front of the line in the report file and string compare with pattern file.
patter file: pattern1.txt
pattern num
like 4
love 3
john 2
report file: report.txt
i like very much
but john is good boy
i will love u
so after execute... (9 Replies)
Hi Guys,
I am new to the forum and to scripting so bear with me.
Thanks, Gary.
I have 3 files - file1, file2, file3
I am trying to come up with a script that will check the output of these files and if the 1st nine fields are matched in all 3 files, echo "The following string had been... (2 Replies)
I have a bunch of conf files, that contain the fully qualified names of servers. I would like to be able to use some sort of pattern matching with sed or vi, or whatever, to pull out the fully qualified server names, and dump them in a file.
It just needs to work across several unix os. So, I... (4 Replies)
Hi all,
if I have the following piece (repeating) of text within a file and I wish to delete it via sed
a
b
c
d
e
<tr>
<td><img alt="" height="1" width="3" src="/testweb/view/browser/images/shim.gif"></td><td><img alt="" height="1" ... (4 Replies)
All,
I have the following file:
--------------------------------------
#
# /etc/pam.d/common-password - password-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define the services... (2 Replies)
Hello,
Despite reading the Pattern Matching chapter in the O'Reilly Sed & Awk book several times and
looking at numerous examples, I cannot seem to get any kind of conditional script to work in my awk scripts!
I am able to do the basic awk and grep script to capture the data but when I do with... (0 Replies)
MSG="THERE WERE XX RECORDS IN ERROR TABLE,AAAA, WHEN LOADING THE BBBB TABLE WITH EXTRACT FROM CCCC INTO TABLES FOR , DATABASE DDDD."
echo "$MSG" > /tmp/mplanmsg.$$.out
I wan to replace XX with the content in $recordXX
cat /tmp/mplanmsg.$$.out|sed 's/XX/\$recordXX/g'| sed... (3 Replies)