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 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 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
I am very new to TCL but am very familiar with shell scripting and currently looking at a system that is using TCL. I want to use functions/procedures in the TCL script but keep getting an error message that it cannot find "ssName". This is the very first function there will be more and am...
gawk ' BEGIN { sitea=0 ; siteb=0 }
{
if ($1 ~ "192.168.6") { sitea++ } else { siteb++ }
x[sitea","siteb","$7","$9]
}
END {
for (i in x)
print i
}' $FILE
No doubt and probably needless to say...
I have used the following code and was delighted with it until today.
/usr/bin/find . -type f -iname '*' -printf "%h\n" | uniq -c | grep content | gawk '{print substr($2,3),$1}'
The above counts files in a directory and displays
directoryname filecount
Someone pointed out to me today...
I have a file similiar to this...
field1:wxyz field2:"aa bb ccc" field3:xxxx ...etc
field1:zyx field2:"aa bbb cc dd" field2:yyy ...etc
field1:pq field2:"aaa b" field3:zz ...etc
I want to display
field2:"aa bb ccc"
field2:"aa bbb cc dd"
field2:"aaa b"
I have tried alot of...
I have a directory listing with files that keep updating and I need to check the last modify/access time of the directory plus the total number of files in that directory.Keeping the newest/latest modified directory listing at the top.
For example...
[root@instructor home]# ls -ltR mydir*...
#for MINUTE in `cat timelist` A file with 60 numbers in ranging from 00 to 59
do
gawk -v hr=$HOUR -v min=$MINUTE -v rdate=$RDATE 'BEGIN {OFS=",";sstr=hr":"min;maxfs=0;print "DATE","TIME","COUNT","COUNT200","UNDER1","ONE2FIVE","FIVE2TEN","TEN2TWEN","TWEN2FOR","OVER40","HASHCOUNT","BLKED"}
{
if...
I am getting odd output. Any help appreciated,
Madasafish
Code:
gawk '{
for (i = 1; i <= 500; i=i+100)
if (substr ($0,10,4) > i && (substr ($0,10,4) <i+100))
print $0 " Location_"i"-"i+99
}' $infile
$infile
D200805301 3320842 1.00
D200805302 3320842 1.00
D2008053010 3320842...
I have "week" file with $1 in a series.
Example week file
042007|27/06-21:52:35|27/06-21:52:38|27/06-21:52:41|66
032007|27/06-21:52:35|27/06-21:52:38|27/06-21:52:41|66
022007|27/06-21:52:35|27/06-21:52:38|27/06-21:52:41|66
012007|27/06-21:52:36|27/06-21:52:38|27/06-21:52:41|66...
example:
Note: The 1 to 9 string shown here could easily be
1 to 900
echo "1 2 3 4 5 6 7 8 9" |nawk '{print $2,$(NF-1)}'
gives me
2 8
What I would like is:
2 3 4 5 6 7 8
Any help appreciated.
Madasafish2
Please advise on how to get nawk to print out the contents of the getline field:
Many Thanks,
Madasafish
rangefile:
hello world
myfile:
goodbye world
hello sir
Wanted result
hello sir|world
Code:
BEGIN {
while (getline < rangefile) {...
I want tbe able to call a nawk function that will print out a set of lines. The first time the function
is called it will print to the screen. The second time it is called I will call the funtion with a ">" at the end
to re-direct output to a file. I appreciate I could repeat all the lines with...
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.