Sponsored Content
Full Discussion: awk completes early
Top Forums Shell Programming and Scripting awk completes early Post 302129304 by nhatch on Monday 30th of July 2007 10:47:11 AM
Old 07-30-2007
awk completes early

Hi All.....

I have a text file with a good number of rows, example below. The script is to work out percent of failures. The problem I have is that the script exits after the first result is given. From this example here I should have two output lines, one from GetOffers and ListOffers. Any idea why this may be?

Quote:
(I) Jul 27 09:18:44:900 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1: Service[ListOffers] started
(I) Jul 27 09:19:01:220 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1: service [GetOffers] returns [0]
(I) Jul 27 09:19:28:777 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : Service[ListOffers] started
(I) Jul 27 09:19:32:698 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : service[ListOffers] returns [-1]
(I) Jul 27 09:19:48:878 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : Service[ListOffers] started
(I) Jul 27 09:19:51:316 TIB_TUX_EXC2CCOS_SERVER[ 27527] user1 : service[ListOffers] returns [0]

Code:
percent()
{

awk -- 'BEGIN{EQUATION='"$*"';printf("%0.1f%\n",EQUATION)}'


}

order()
{

echo Start ordering

grep "] started" $file | awk '{print $10}' | sort | uniq | while read line
do

line=${line#\[}
line=${line%]}

started=`grep "] started" $file | grep -c $line`
returns=`grep "returns \[" $file | grep -c $line`
failreturn=`grep "returns \[-1" $file | grep -c $line`

printf "Fail percent on $line = \c"

percent "$failreturn / $returns * 100"

echo $line
#printf "\n"

done

}

while getopts f:ohd name
do
        case $name in
                f)
                        file="$OPTARG";;
                o)
                 order;;
                h)
                 hourly;;
                d)
                 day;;
                *)
                 usage;;
        esac

done

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append Status to echo'd line after process completes

Hello All, I'm very new to scripting and I'm writing a very simple script to restart a couple processes because I'm getting to lazy to cd between directories. This is pretty much my first script and I just want to add a little cosmetics to it. Here's what I have: #!/bin/ksh echo... (5 Replies)
Discussion started by: Setan
5 Replies

2. Shell Programming and Scripting

remove directory x seconds after script completes

Hi guys, I am working with a script within a Mac OS X package installer. The package installer will run the bash script once the files have been copied/installed. I have a little trouble with the last line of my script causing the package installer to crash once in a while and I have narrowed it... (1 Reply)
Discussion started by: tret
1 Replies

3. UNIX for Advanced & Expert Users

how to delay a process getting killed before it completes its work

The problem i am encountering is the process is getting killed before it dispalys the details.The details are displayed using printf.I created a new buffer for printing the details using setvbuf function call instead of output buffer.This is not working.The thing is,killing of the process must be... (1 Reply)
Discussion started by: cijkmysj
1 Replies

4. UNIX Benchmarks

Early PowerMac G5

Hardware Overview: Model Name: Power Mac G5 Model Identifier: PowerMac7,2 Processor Name: PowerPC 970 (2.2) Processor Speed: 1.8 GHz Number Of CPUs: 2 L2 Cache (per CPU): 512 KB Memory: 1.5 GB Bus Speed: 900 MHz Boot ROM Version:... (0 Replies)
Discussion started by: tnorth
0 Replies

5. Shell Programming and Scripting

Read file contents and separate the lines when completes with =

Hi, I have a file like this cpsSystemNotifyTrap='2010/12/14 11:05:31 CST' Manufacturer=IBM ReportingMTMS=n/a ProbNm=26 LparName=n/a FailingEnclosureMTMS=7946-IQL*99G4874 SRC=B3031107 EventText=Problem reported by customer. CallHome=true Calendar I want to have a output like this... (6 Replies)
Discussion started by: dbashyam
6 Replies

6. Shell Programming and Scripting

While loop - how to run processes one after another (2nd starts after first completes, and so on)

I'm a programming noob. I'm trying to run a memory intensive process for many files. But when I use the following script, it runs fine for the first 5-7 files, then runs out of memory. Monitoring the output files, it's clear the processes are going on in parallel. Once 5-7 of the files are being... (18 Replies)
Discussion started by: pathunkathunk
18 Replies

7. Shell Programming and Scripting

<< Environmental Variables are not set when script completes >>

Hi Team, I have a wrapper script which i have pasted below, it internally calls one python script to generate Environmental in a file called /home/oracle/myenv.sh, when i execute this script via wrapper script, its not reflecting in my current session, still showing old env variables. any... (2 Replies)
Discussion started by: kamauv234
2 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy