radoulov & fpmurphy,
I can't thank you both enough for what you guys did. I had to tweak both scripts a little bit, but both are working. I realize I was going about this the wrong way. Both have helped me enormously.
radoulov,
I am having trouble following your logic, it looks like there are "shortcuts" in your script that I am having problem deciphering. Can you explain your script for me.
[...]
radoulov,
I am having trouble following your logic, it looks like there are "shortcuts" in your script that I am having problem deciphering. Can you explain your script for me.
[...]
For every record that matches the pattern ^CP: print it and increment the value of the parameter f. We only need a flag, you can use flag = "true" if you consider it more readable.
Code:
f {
if ($0 ~ /TCS /) {
if (edm) {
printf "----\n%-8s %-8s\n", tcs, edm
edm = ""
}
tcs = (($1) FS ($2))
}
For every record for which our flag is true, has value different than zero or null - the f by itself (here we are in your logical record/block):
+ if the record matches the pattern TCS<space>:
++ if the parameter edm is true (see below), then print the values of the parameters tcs and edm, then unset edm (set it to "", false)
++ set the parameter tcs to the values of $1 FS and $2.
+ if the record matches the pattern EDM|WRC|wrc (EDM OR WRC OR wrc) go to the next line (getline) and:
++ increment edm and edmt (total) with the sum of $1 and $2.
+ if the record has no fields (a blank line, the end of your logical record/block), print the values of tcs, edm, edmt (total) and unset f,tcs, edm and edmt.
I think I got it now. I was getting confused on the first edm statement, I was wondering how it becomes true, until I relized script goes until it finds a blank line and then prints out varables and resets varables at the end. I also did not know that a varable can be used in the pattern part of a awk script. Again thanks, you have no idea how much I struggled on this.
Hello fellow unix geeks,
I am having a small dilemna trying to parse a log file I have. Below is a sample of what it will look like:
MY_TOKEN1(group) TOKEN(other)|SSID1
MY_TOKEN2(group, group2)|SSID2
What I need to do is only keep the MY_TOKEN pieces and where there are multiple... (7 Replies)
I have 1.6 GB (and growing) of files with needed data between the 11th and 34th line (inclusive) of the second column of comma delimited files. There is also a lot of stray white space in the file that needs to be trimmed. They have DOS-like end of lines.
I need to transpose the 11th through... (13 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I want add a line.For example:-
123456 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25
its answer... (4 Replies)
Hello,
I have a similar problem so I continue this thread.
I have:
my_script_to_format_nicely_bdf.sh | grep "RawData" |tr -s ' '|cut -d' ' -f 4|tr -d '%'
So it supposed to return the percentage used of RawData FS:
80
(Want to use it in a alert script)
However I also have a RawData2 FS so... (17 Replies)
Hi,
After looking on different forums, I'm still in trouble to parse a parameters line received in KSH.
$* is equal to "/AAA:111 /BBB:222 /CCC:333 /DDD:444"
I would like to parse it and be able to access anyone from his name in my KSH after.
like
echo myArray => display 111
... (1 Reply)
Hi all,
I am having problems parsing the following file:
cat mylist
one,two,three
four
five,six
My goal is to get each number on a seperate line.
one
two
three
four
five
six
I tried this command:
sed -e 's/\,/^M/g' mylist (11 Replies)