Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: madasafish
  • Content: Threads
  • Order by date
  1. madasafish

    Convert Nagios .cfg files to CSV

    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...
  2. madasafish

    Transpose column to line but with a difference

    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...
  3. madasafish

    Convert local time string to UTC

    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...
  4. madasafish

    A simple lesson in Arrays?

    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...
  5. madasafish

    Search for Pattern, Print the line and print the next 10 or x lines below it

    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
  6. madasafish

    Newbie and TCL script construct

    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...
  7. madasafish

    Sub-totalling an array

    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...
  8. madasafish

    Multiple if with one else syntax

    gawk 'BEGIN {} !/btvtracker/ { next } { split (substr ($12,50),a,"&");clickthru=a[1];etvchannel=a[2] split (etvchannel,b,"=");chantype=b[1];channo=b[2] x[channo","clickthru]++ } END { for (y in x) { split...
  9. madasafish

    Counting files in subdirectories?

    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...
  10. madasafish

    cygwin gawk and XML files

    <configuration>MediacastCarousel_abc_dynamic<variable>^M^M <name>Cdf.PollingInterval</name>^M^M <value>60</value>^M^M <type>string</type>^M^M <grouplevel>3</grouplevel>^M^M <permission>0</permission>^M^M <groupname>ngetv1</groupname>^M^M </variable>^M^M...
  11. madasafish

    Simple split?

    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...
  12. madasafish

    using awk to display elements of a directory listing

    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*...
  13. madasafish

    Gawk for loop, incrementing counter and fastest speed

    #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...
  14. madasafish

    Using nawk &quot;if&quot; like a shell case statement

    #!/bin/ksh LOG=/var/log/oss/libiiop/libiiop_11-06-21_08:00.log TMPLOG1=/tmp/templog1.log TMPLOG2=/tmp/templog2.log #nawk -F"mid=" '{print substr ($2,1,12)}' $LOG > $TMPLOG1 #sort -u $TMPLOG1 | grep -v "^;" > $TMPLOG2 nawk '{a[substr ($0,1,6)]++}END{for (i in a) printf "%-6s -> %-2d \n", i...
  15. madasafish

    Using &quot;for&quot; loop in gawk - Odd output?

    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...
  16. madasafish

    Match on Field1 and Field 2. If no match on Field3, print

    File1: DC000600CN003350647 290 1 DC000600CN003350647 291 33 DC000600CN003350647 292 0 DC000600CN003350647 293 0 DC000600CN003350647 294 0 File2: DC000600CN003350647 290 2 DC000600CN003350647 291 33 DC000600CN003350647 292 0...
  17. madasafish

    print $1 between given start and given end

    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...
  18. madasafish

    Printing all fields between 1st and last field

    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
  19. madasafish

    getline 2 fields then print match + content of field 2 in first file

    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) {...
  20. madasafish

    Calling a simple print function

    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...

Part and Inventory Search

Back
Top