Sponsored Content
Full Discussion: Help with awk script
Top Forums UNIX for Dummies Questions & Answers Help with awk script Post 302907833 by nybbles2bytes on Wednesday 2nd of July 2014 04:35:02 AM
Old 07-02-2014
Awesome. I used your second example so this works as desired:
Code:
#!/bin/awk -f

BEGIN{
  #
  # LookBack should be something like "1 hour" or "1 day" and is set on the command line with
  # -v LookBack='1 hour'. Best to make it the same and the crontab set frequency for calling
  # this script.
  #
        "date -d \"-"LookBack"\" \"+%s\""|getline RefDate;
  close("date -d \"-"LookBack"\" \"+%s\"");
  split("jan feb mar apr may jun jul aug sep oct nov dec", months, " ");
}
{
  s = tolower($4);
  gsub(/\//, ":", s);
  sub(/\[/, "", s);
  split(s, a, ":");
  for (i = 1; i < length(months); i++) {
    if (months[i] == a[2]) {
      a[2] = sprintf("%02d", i);
      break;
    }
  }
  LogDate = mktime(a[3]" "a[2]" "a[1]" "a[4]" "a[5]" "a[6]);
  if (RefDate < LogDate) {
    if (/rewrite +.?(assets\/.+.? +-> +.?sites\/default\/files\/|sites\/default\/files\/.+.? +-> +.?assets\/)./) {
      if (! /injector|css\/css_/) {
        # $11 = file with path that is being rewritten to another directory
        fn = $11;
        gsub(/[']/, "", fn);
        print $4,$5,$10,$11,$12,$13 "\nLines from access_log with the file:", fn;
        cmd = "grep -F \"" fn "\" /var/log/httpd/access_log";
        while((cmd | getline line) > 0) {
          print line;
        }
        close(cmd);
        print "\n";
      }
    }
  }
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

want to pass parameters to awk script from shell script

Hello, I have this awk script that I want to execute by passing parameters through a shell script. I'm a little confused. This awk script removes duplicates from an input file. Ok, so I have a .sh file called rem_dups.sh #!/usr/bin/sh... (4 Replies)
Discussion started by: script_op2a
4 Replies

3. Shell Programming and Scripting

Call shell script function from awk script

hi everyone i am trying to do this bash> cat abc.sh deepak() { echo Deepak } deepak bash>./abc.sh Deepak so it is giving me write simply i created a func and it worked now i modified it like this way bash> cat abc.sh (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

4. Shell Programming and Scripting

Help: How to convert this bash+awk script in awk script only?

This is the final first release of the dynamic menu generator for pekwm (WM). #!/bin/bash function param_val { awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2 } echo "Dynamic {" for CF in `ls -c1 /usr/share/applications/*.desktop` do name=$(param_val Name $CF) ... (3 Replies)
Discussion started by: alexscript
3 Replies

5. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

7. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

8. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

9. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

10. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies
DateTime::Locale::ia(3) 				User Contributed Perl Documentation				   DateTime::Locale::ia(3)

NAME
DateTime::Locale::ia SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'ia' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Interlingua. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) lunedi martedi mercuridi jovedi venerdi sabbato dominica Abbreviated (format) lun mar mer jov ven sab dom Narrow (format) 2 3 4 5 6 7 1 Wide (stand-alone) lunedi martedi mercuridi jovedi venerdi sabbato dominica Abbreviated (stand-alone) lun mar mer jov ven sab dom Narrow (stand-alone) 2 3 4 5 6 7 1 Months Wide (format) januario februario martio april maio junio julio augusto septembre octobre novembre decembre Abbreviated (format) jan feb mar apr mai jun jul aug sep oct nov dec Narrow (format) 1 2 3 4 5 6 7 8 9 10 11 12 Wide (stand-alone) januario februario martio april maio junio julio augusto septembre octobre novembre decembre Abbreviated (stand-alone) jan feb mar apr mai jun jul aug sep oct nov dec Narrow (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Quarters Wide (format) 1-me trimestre 2-nde trimestre 3-tie trimestre 4-te trimestre Abbreviated (format) T1 T2 T3 T4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1-me trimestre 2-nde trimestre 3-tie trimestre 4-te trimestre Abbreviated (stand-alone) T1 T2 T3 T4 Narrow (stand-alone) 1 2 3 4 Eras Wide ante Christo post Christo Abbreviated a.Chr. p.Chr. Narrow a.Chr. p.Chr. Date Formats Full 2008-02-05T18:30:30 = martedi, 2008 februario 05 1995-12-22T09:05:02 = venerdi, 1995 decembre 22 -0010-09-15T04:44:23 = sabbato, -10 septembre 15 Long 2008-02-05T18:30:30 = 2008 februario 5 1995-12-22T09:05:02 = 1995 decembre 22 -0010-09-15T04:44:23 = -10 septembre 15 Medium 2008-02-05T18:30:30 = 2008 feb 5 1995-12-22T09:05:02 = 1995 dec 22 -0010-09-15T04:44:23 = -10 sep 15 Short 2008-02-05T18:30:30 = 08/02/05 1995-12-22T09:05:02 = 95/12/22 -0010-09-15T04:44:23 = -10/09/15 Default 2008-02-05T18:30:30 = 2008 feb 5 1995-12-22T09:05:02 = 1995 dec 22 -0010-09-15T04:44:23 = -10 sep 15 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = martedi, 2008 februario 05 18:30:30 UTC 1995-12-22T09:05:02 = venerdi, 1995 decembre 22 09:05:02 UTC -0010-09-15T04:44:23 = sabbato, -10 septembre 15 04:44:23 UTC Long 2008-02-05T18:30:30 = 2008 februario 5 18:30:30 UTC 1995-12-22T09:05:02 = 1995 decembre 22 09:05:02 UTC -0010-09-15T04:44:23 = -10 septembre 15 04:44:23 UTC Medium 2008-02-05T18:30:30 = 2008 feb 5 18:30:30 1995-12-22T09:05:02 = 1995 dec 22 09:05:02 -0010-09-15T04:44:23 = -10 sep 15 04:44:23 Short 2008-02-05T18:30:30 = 08/02/05 18:30 1995-12-22T09:05:02 = 95/12/22 09:05 -0010-09-15T04:44:23 = -10/09/15 04:44 Default 2008-02-05T18:30:30 = 2008 feb 5 18:30:30 1995-12-22T09:05:02 = 1995 dec 22 09:05:02 -0010-09-15T04:44:23 = -10 sep 15 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 mar 1995-12-22T09:05:02 = 22 ven -0010-09-15T04:44:23 = 15 sab Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 p.m. 1995-12-22T09:05:02 = 9:05 a.m. -0010-09-15T04:44:23 = 4:44 a.m. Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 p.m. 1995-12-22T09:05:02 = 9:05:02 a.m. -0010-09-15T04:44:23 = 4:44:23 a.m. M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = mar, 2-5 1995-12-22T09:05:02 = ven, 12-22 -0010-09-15T04:44:23 = sab, 9-15 MMM (LLL) 2008-02-05T18:30:30 = feb 1995-12-22T09:05:02 = dec -0010-09-15T04:44:23 = sep MMMd (MMM d) 2008-02-05T18:30:30 = feb 5 1995-12-22T09:05:02 = dec 22 -0010-09-15T04:44:23 = sep 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = mar feb 5 1995-12-22T09:05:02 = ven dec 22 -0010-09-15T04:44:23 = sab sep 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = februario 5 1995-12-22T09:05:02 = decembre 22 -0010-09-15T04:44:23 = septembre 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = mar februario 5 1995-12-22T09:05:02 = ven decembre 22 -0010-09-15T04:44:23 = sab septembre 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = mar, 2008-2-5 1995-12-22T09:05:02 = ven, 1995-12-22 -0010-09-15T04:44:23 = sab, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 feb 1995-12-22T09:05:02 = 1995 dec -0010-09-15T04:44:23 = -10 sep yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = mar, 2008 feb 5 1995-12-22T09:05:02 = ven, 1995 dec 22 -0010-09-15T04:44:23 = sab, -10 sep 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 februario 1995-12-22T09:05:02 = 1995 decembre -0010-09-15T04:44:23 = -10 septembre yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 T1 1995-12-22T09:05:02 = 1995 T4 -0010-09-15T04:44:23 = -10 T3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week lunedi SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::ia(3)
All times are GMT -4. The time now is 05:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy