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 strongm 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: Grant
  • Order by date
  1. Grant

    Re-post of Awk Data Processing Question

    Hi AwkRookie, Ha! I'm such a dope. I just repeated the mistake I was telling you about. My message SHOULD have read: I think your code sample isn't displaying quite right. This is because '[i]' in the code that got interpreted as a TGML instruction instead of as an array subscript. You...
  2. Grant

    Re-post of Awk Data Processing Question

    Hi AwkRookie, I think your code sample isn't displaying quite right. This is because '[i]' in the code that got interpreted as a TGML instruction instead of as an array subscript. You might want to unclick the 'Process TGML' checkbox just below the Reply editor. When you resend your code, you...
  3. Grant

    Nawk question!

    Hi piggy213, The top line (#!/usr/bin/awk -f) is called the 'shebang line'. The shebang line tells the Unix/Linux environment that this is specifically an awk script (as opposed to a Bourne-shell or c-shell script, for example). You need a different shebang line for awk, c-shell...
  4. Grant

    Nawk question!

    Hi, Earlier I mentioned that you could use the Unix/Linux date command with special formatting capabilities. I thought I would take the opportunity to show how they can be used. First I will show an excerpt from the man page for date (on an AIX box) with an example, then I will show a small...
  5. Grant

    Nawk question!

    Hi piggy213, Well, I think marsd has pretty much given you everything you need, except I think you are saying that the '/error/' line might not necessarily show up on the line immediately following the date. With that in mind, I wrote the following, but it's totally based on marsd's stuff...
  6. Grant

    Nawk question!

    Hi piggy213, If strftime() is not available, I think you could use getline to get the system date (using the *nix 'date' command). You might want to use it's format string features, so if you are not familiar with them, you would have to check the man pages (man date). (Sorry, I would get it...
  7. Grant

    Nawk question!

    Hi marsd, Is strftime() a nawk built-in function, or just gawk? Grant
  8. Grant

    executing commands with awk field

    Hi sinebubble, I wonder if you have thought of trying it using getline, instead of system? Eg: #!/bin/sh df -k | grep -v cdrom | grep -v : | sed 1d | sed 's#%##' | awk ' { if ( $5 > 10 ) { print "ALERT: "$6 " is " $5 "% full on " } else...
  9. Grant

    executing commands with awk field

    Hi sinebubble, Do we know for sure that it is going into the 'else if' block so that it is reaching the system() call? ie: else if ( $5 > '$MAIL_NUMBER' ) { print "WARNING: "$6 " is " $5 "% full on "; system("du -adko "$6" |...
  10. Grant

    executing commands with awk field

    Hi sinebubble, By the way, I am suspicious of the reference to $PAGE_NUMBER and $MAIL_NUMBER. It looks like these are supposed to be shell variables. I can't test it right now, but I'm pretty sure you can't reference them directly from within awk. (Excuse me in advance if you know otherwise)...
  11. Grant

    executing commands with awk field

    Hi sinebubble, I unravelled your code and it looked like this: df -k | grep -v cdrom | grep -v : | sed 1d | sed 's#%##' | awk '{ if ( $5 > '$PAGE_NUMBER' ) { print "ALERT: "$6 " is " $5 "% full on " } else if ( $5 > '$MAIL_NUMBER' ) { print...
  12. Grant

    counting occurances and sort in descending oder

    Hi dvanan, In your previous message, you said: >Tried some debug but I'm quite new to the "for ( a in b)" syntax so was st(r)uck ! It's quite straightforward. You can print each subscript in the array using the following syntax: for ( variable in array ) { print variable; }...
  13. Grant

    counting occurances and sort in descending oder

    Hi dvanan, I forgot to turn off TGML and it treated a '[i]' as a command to italicize. So here is the new version once again: #!/usr/bin/awk -f BEGIN{ a[0]=32 a[1]=10 a[2]=32 a[3]=14 a[4]=16 a[5]=10 a[6]=32 for ( i in a ) { b[a[i]]+=1; } for ( count=1; count<=3...
  14. Grant

    counting occurances and sort in descending oder

    Hi dvanan, Here's the new version: #!/usr/bin/awk -f BEGIN{ a[0]=32 a[1]=10 a[2]=32 a[3]=14 a[4]=16 a[5]=10 a[6]=32 for ( i in a ) { b[a[i]]+=1; } for ( count=1; count<=3; count++) { highest=0; for ( j in b ) { if (highest < b[j]){ highest=b[j]...
  15. Grant

    counting occurances and sort in descending oder

    Hi dvanan, Whoops! I misunderstood something. Let me take another look. Grant.
  16. Grant

    counting occurances and sort in descending oder

    Hi dvanan, Try this: #!/usr/bin/awk -f BEGIN{ a[0]=32 a[1]=10 a[2]=32 a[3]=14 a[4]=16 a[5]=10 a[6]=32 for ( i in a ) { b[a[i]]+=1; } for ( count=1; count<=3; count++) { highest=0; for ( j in b ) { if (highest < j){ highest=j } } print...
  17. Grant

    How can run a DOS command inside a perl script..Plz help!

    Good point PaulTEG! Grant.
  18. Grant

    How can run a DOS command inside a perl script..Plz help!

    Hi ejaj, I realize this does not answer the question as to why the dos copy command is failing when using the backtick technique, but if you are only interested in copying files, perhaps you might try File::Copy. If you are using ActiveState Perl, it should be included. use File::Copy...
  19. Grant

    Awk questions

    Hmmm, I am puzzled. I ran the identical code on my box and, as expected, it works just fine. Therefore it's not syntax. My conclusion is that getline exists on your system, but it seems to be too primitive to support the functionality that we take for granted. Apparently, you just have an...
  20. Grant

    How do I read the bits of a binary file?

    Hi breveR, It sounds like you want to look into the 'pack' and 'unpack' functions. Hope this helps, Grant.

Part and Inventory Search

Back
Top