Sponsored Content
Full Discussion: Awk modification
Top Forums Shell Programming and Scripting Awk modification Post 302648941 by SkySmart on Wednesday 30th of May 2012 02:26:03 PM
Old 05-30-2012
Awk modification

I need help modifying the code below.

DATAFILE is a log file.

I have two strings i need to search for in the log file.

The two strings are:

1. ERROR
2. com.rolander.promotions.client



Code:
awk 'BEGIN {
  while((getline < "'${SFILE}'")>0)
     S[$0]

  FS="\n"; RS="\n"
}

/ERROR/ && /com.rolander.promotions.client/ {

  for(X in D) delete D[X];

  for(N=2; N<=NF; N++)
  {
       gsub(/^[ \t]+/, "", $N);
       split($N, A, "=");
       D[A[1]] = A[2]
       i = 3;
       while (i in A)
          D[A[1]] = D[A[1]] "=" A[i++];
  }

       printf("%s \n")

}' $DATAFILE

SFILE is suppose to be a file that contains the strings to search for. one string per line. i guess this is redundant since i already hardcoded the strings in the script.

sample log file:


Code:
2012-05-30 17:55:58,296 ERROR com.rolander.core.manager.paymentManager.PaymentBL - PaymentBL notifyPaymentOK() method is called. This functionality is not supported.
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception with communication with promotions web service: 
2012-05-30 17:56:02,855 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service host: promo.rolandernetworks.net
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service port: 8080
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service path: /promotions/getReferral
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service params: subAccountNumber=101045334
2012-05-30 17:56:02,856 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service http timeout: 10000
2012-05-30 17:56:02,857 ERROR com.rolander.promotions.client.PromotionsWebServiceClient - Exception web service tcp timeout: 1000
2012-05-30 17:56:02,857 ERROR com.rolander.core.manager.referralManager.ReferralBL - ERROR getting Referral.

basically, i want the script to scan this file and output ONLY lines that contain the two strings i specified.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Swap modification

How can i modify (expand) the swap memory (Sco Enterprise 5.0.5) using the swap command...? The excisting swap is 512 and i want to increase it to 1024...? Thanx in advance (2 Replies)
Discussion started by: psychofredy
2 Replies

2. Shell Programming and Scripting

in line modification in a file using awk

Hi, I have a conf.file with the following values: ef=78 b=40 ca=40 c=45/dev2 when I modify one of the line with the below awk script,it's modifying BUT it's placing the modified line in the last line : input:- Configure b 45/dev4 output:- ef=78 ca=40 ... (2 Replies)
Discussion started by: axes
2 Replies

3. Shell Programming and Scripting

awk script modification

I want the below script to omit every chunk of data that contains a specific hostname. here's the scenario. i have a configuration file that contains the configuration of several hosts. a sample of this configuration file is this: define host { address ... (12 Replies)
Discussion started by: SkySmart
12 Replies

4. Shell Programming and Scripting

awk modification for lines

so i have this data in a file: jime=1860,yime=1.23243,lime= jime=1859,yime=1.23018,lime= jime=1825,yime=1.15371,lime= jime=1849,yime=1.20769,lime= jime=1841,yime=1.1897,lime= jime=1849,yime=1.20769,lime= i use this code to calculate the percentage difference of the number in column 2... (9 Replies)
Discussion started by: SkySmart
9 Replies

5. UNIX for Dummies Questions & Answers

awk output modification

Hello, I am using awk command to print some output, but there are some characters that I would like to remove from the output awk '{print $5$6}' the output I get is column5/:column6 I am looking forward to remove the : and to get the output column5/column6 Sorry if this question is... (4 Replies)
Discussion started by: Error404
4 Replies

6. Shell Programming and Scripting

IP Address Modification through awk/sed

Hi, I have to modify the 2nd and 3rd octet of the IP address through awk/sed. For Example: Given IP is : 10.205.22.254, it should be modified as 10.105.100.254 through awk/sed. Kindly help me on this and let me know if you have any questions. Thanks in advances. (2 Replies)
Discussion started by: kumarbka
2 Replies

7. Shell Programming and Scripting

awk script modification - treat certain files differently

awk 'BEGIN{OFS=","} FNR == 1 {if (NR > 1) {print fn,fnr,nl} fn=FILENAME; fnr = 1; nl = 0} {fnr = FNR} /UNUSUAL/ && /\.gz/ ~ /FILENAME/ {nl++} <'{system ("gunzip -cd FILENAME")}' END ... (2 Replies)
Discussion started by: SkySmart
2 Replies

8. Shell Programming and Scripting

awk script modification

can someone help me identify what i'm doing wrong here: awk -F'|' 'BEGIN{c=0} /./ && /./ { if ($3 < 2) { print ; c++ } END { print c":OK" } else if (($3 >= 2) && ($3 < 4)) { print ; c++ } END { print c":WARNING" } else if ($3 >= 4) { print ; c++ } END { print c":CRITICAL" } }'... (4 Replies)
Discussion started by: SkySmart
4 Replies

9. Shell Programming and Scripting

Modification to awk command

i have a php file that has this: php.code #!/usr/bin/php <?php phpinfo(); hlight_file(__FILE__); ?> I want my awk code grab whatever is inbetween and including the "<?php" and "?>". Then, it should scan all the entries between these two points. And if the entries between these... (10 Replies)
Discussion started by: SkySmart
10 Replies

10. UNIX for Beginners Questions & Answers

cp modification

I'm usia Raspbian, a Debian subset, and wondering what work would be involved in altering the cp command. cp at present needs a full path and file name for source and at least full filename for destination. How can I change this so the second parameter isn't needed? So if the destination... (6 Replies)
Discussion started by: MuntyScrunt
6 Replies
scrl(3XCURSES)						  X/Open Curses Library Functions					    scrl(3XCURSES)

NAME
scrl, scroll, wscrl - scroll a window SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int scrl(int n); int scroll(WINDOW *win); int wscrl(WINDOW *win, int n); PARAMETERS
n number and direction of lines to scroll win pointer to the window in which to scroll DESCRIPTION
The scroll() function scrolls the window win up one line. The current cursor position is not changed. The scrl() and wscrl() functions scroll the window stdscr or win up or down n lines, where n is a positive (scroll up) or negative (scroll down) integer. The scrollok(3XCURSES) function must be enabled for these functions to work. RETURN VALUES
On success, these functions return OK. Otherwise, they return ERR. ERRORS
None. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
clearok(3XCURSES), libcurses(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 scrl(3XCURSES)
All times are GMT -4. The time now is 05:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy