Thanks PHV...of course it works!
Wish I could understand it...
Looks like the for loop on an array is substituting the match on another array "for(i in thn)sub(i,thn[i])"
Madasafish
gawk version 4.0.1
Certainly,
Your code works perfectly.
All that was missing was an "exit 0". I cut and paste your code above my futile attempts shown above.
so after your code, it also ran...
FILE="test"
gawk -F"," '{ if($5 == 1) { printf $1"," }
}' $FILE
exit 0
In my haste to reply and thank-you, I...
This is the approach so far....I know it's not right
for INFILE in lang_liberate.cfg
do
gawk 'BEGIN{RS=""}
if ($0 ~ "define hostgroup{") {
if ($1 ~ /hostgroup_name/ { hgn=$2 }
if ($1 ~ /members/ { mem=$2 }...
I think this is another array exercise :-(
Here is an example of a Nagios .cfg file.
define host{
use host-liberate
check_command check-host-alive
max_check_attempts 3
host_name squid01.lang.dtv
alias...
I have tried many awk "transpose" suggestions from the net and also tried to amend them to give me the output I want but to no avail.
I manually generated the output shown above with the first piece of code shown below and changed the $5 to suit column and cut and paste into code section.
When...
I have another conundrum...I hope someone can help me with?
My input data - I have only shown 5 column's (Packs), there are in fact 56 columns and 350 records
CH#,M Pack,M+ Pack,L Pack,XL Pack,etc...
100,1,1,1,1
101,1,1,1,1
102,1,1,1,1
103,1,1,1,1
104,1,1,1,1
105,1,1,1,1
106,1,1,1,1...
I am using gawk version 4.0.0 and reading a file that has local time strings in two of the CSV fields and would like to convert these strings to UTC time strings.
This is a monthly exercise and local time will automatically change depending on the time of the year.
$ date
Sat Apr 6 09:55:30...
I was trying to simplify it with the emphasis on what is the method of getting a 4th parameter (in my case) that could lie anywhere else in the file. It is true, there is no mention of fred bert harry in the real data I am using.
Noted.
I can get the desired result but it means I have to...
Yikes!....I was under the impression this was simple and was looking for the technique and was expecting a slight change and a couple of lines extra, which was why I simplified it so that it is easier for the readers to understand. Is it really that complicated?. It would be simpler to parse the...
I am reading a XML file and can capture poid, poname and huid parameters easily but am struggling to catch the fourth parameter "suid" because it matches on "huid" at another random line in the file.
I have simplified the issue with the data shown below. The "...." in the example shown below...
I have seen this snippet of code somewhere and have trawled back 10 pages looking for it.
Apologies if this is a repeat question on the forum.
Please note there will be multiple occurrences of "Pattern".
Thanks in advance
Madasafish
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.