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 Mike Lewis 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: *

  1. madasafish

    Convert Nagios .cfg files to CSV

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

    Transpose column to line but with a difference

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

    Convert Nagios .cfg files to CSV

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

    Transpose column to line but with a difference

    Yep...That works!....needs a bit of tidy up on the last output. I would never have worked it out, Thank-you. gawk version 4.0.1
  6. madasafish

    Transpose column to line but with a difference

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

    Convert local time string to UTC

    I forgot to mention the converted UTC Time strings should be in the same format as the local time strings supplied. Many thanks, Madasafish
  9. 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...
  10. madasafish

    A simple lesson in Arrays?

    Same data. Where it has 2 fields the third field is totally (non-matching) random data. How would you do it? Madasafish
  11. madasafish

    A simple lesson in Arrays?

    Can I be bold and invite an academic exercise? [3eyes] How would you approach this if there were 3 fields on all data lines.
  12. madasafish

    A simple lesson in Arrays?

    Nice one! Just one question that is puzzling me. Why this?... if (split(value, tmp_array, ",") == 2) instead of... split(value, tmp_array, ",")
  13. madasafish

    A simple lesson in Arrays?

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

    A simple lesson in Arrays?

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

    A simple lesson in Arrays?

    I appreciate your help with this PHV
  16. madasafish

    A simple lesson in Arrays?

    I appreciate I will have to take "$0 !~ /productOfferingID/ { next }" out of the code to get to the "suid" lines. Madasafish
  17. madasafish

    A simple lesson in Arrays?

    If it helps.... # Third get POID, PO_NAME and HUID gawk -F'" ' ' $0 !~ /productOfferingID/ { next } { split($1,a,"=\"") if (a[2] ~...
  18. madasafish

    A simple lesson in Arrays?

    By the way I am using gawk
  19. 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...
  20. 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

Part and Inventory Search

Back
Top