Sponsored Content
Top Forums UNIX for Dummies Questions & Answers I can't divide properly in shell Post 302170778 by mikez104 on Tuesday 26th of February 2008 03:45:41 PM
Old 02-26-2008
I can't divide properly in shell

I'm new at this and frustratd because I know this must be simple but here goes. I'm trying to write a script that will give me the percentage of a particular field over multiple text files.

Each day I have around 1500 files that are generated. Each file has around 100 lines in it. The lines that I want have LOI in the first field. Each line has 13 fields. The last field either has 0001 (good) or 0002 (bad). I need to find the total lines with LOI and figure the percentage of 0002 of the total.

Getting the total is easy.

total=`grep LOI date* | cut -d" " -f 13 | wc -l`

and getting the bad...

bad=`grep LOI date* | cut -d" " -f 13 |grep 0002| wc -l`

date* gives me all the files for the day in question. So that counts all the records and gets them into a variables. Then I tried

expr $failed / $played

and it just gives me 0.

I then tried this in AWK. I can do this

gawk '/LOI/ {print $13 }' date* | wc -l | gawk '{print "total " $0}'

but can't figure out how to get both values into awk and manipulate them.
please help...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script needs to divide by 2

i need to divide this count by 2, what variable can i use in my script? 26 hcscprod_cpus_totals /2 = 13 13 hcncprod_cpus_totals /2= 6.5 541 ktazp_cpus_totals /2= 270.5 346 ktazd_cpus_totals /2=173 110 ktazi_cpus_totals /2=55 10 ktazq_cpus_totals /2=5 (2 Replies)
Discussion started by: wereyou
2 Replies

2. Shell Programming and Scripting

Shell script not processing if statement properly

Hi I am trying to create a shell script that will look for a contracthead file first and if the contract head file does not exist on day1 exit script. Now on day2 if contracthead exists or not run the script uploading files in order such as contract line then contract contact so the... (2 Replies)
Discussion started by: jonathan184
2 Replies

3. Shell Programming and Scripting

Output in my shell isn't showing properly.

Hi! Can anyone tell me what went wrong in my shell script? for dt_val in `cut -f 1 -d '|' /prod/ods/satyaki/sqlldr/grp.dat` do echo $dt_val done And, the output is - 23 39 (7 Replies)
Discussion started by: satyakide
7 Replies

4. UNIX for Dummies Questions & Answers

Issue with shell script: not detecting file properly

The following script is meant to check the presence of a file - called filename0.94.tar.gz - and uncompress it: #!/bin/sh # check presence of file VERSION=0.94 if ; then # file not present: abort echo "Files cannot be found." #exit 1 (commented out this line, so we can see how the... (2 Replies)
Discussion started by: figaro
2 Replies

5. Shell Programming and Scripting

Shell Script Email not working Properly

Hi GURU's, I'm using a Shell Script to send email's as an attachment. I'm Storing the email address in a table and catching in a variable. MAILLIST=`noarg sqlplus -s $OraUsr << EOF set heading off set feedback off set echo off SELECT email_ids FROM tpemail_table WHERE... (9 Replies)
Discussion started by: karthikraj
9 Replies

6. Shell Programming and Scripting

Shell script not working properly

Hello, i have below shell script to process ftp get from server and create file list afte finish. this shell scipt has 6 parameter input. unfortunately, it is only working to get the file and terminated before creating file list. please help. thanks, #!/bin/ksh ## example usage :... (3 Replies)
Discussion started by: daryatmo
3 Replies

7. Shell Programming and Scripting

Can't get shell parameters to pass properly to sqlplus

Gurus, The issue I'm having is that my Shell won't accept SQL parameters properly...... Here's they way I'm running it.... applmgr@ga006hds => sh CW_MigrationDeployScript.sh apps <appspwd> <SID> '01-JAN' '31-MAR' The process just hangs not submitting the SQL job... ... (3 Replies)
Discussion started by: WhoDatWhoDer
3 Replies

8. Shell Programming and Scripting

Divide two variable

F= `expr $E/$S` output test5.sh: line 45: 1296863.27001857757568359375/21997: No such file or directory can any one help me ,i just want to divide the $E/$S and Print o/p in F. (3 Replies)
Discussion started by: netdbaind
3 Replies

9. Shell Programming and Scripting

Divide by zero script

Hi, I've been working on a few scripts and have been getting great info. How, would I include in the below script, how I would let a user know that if they divide a SECOND number by zero, that they would get a divide by zero error? What's the easiest way of working this? Cordially, joe. ... (1 Reply)
Discussion started by: jefferj54
1 Replies

10. UNIX for Dummies Questions & Answers

To divide file

We have large log files, and we need to extract last four hours lines only, Please let us know the command. Thanks, Saurau. (1 Reply)
Discussion started by: saurau
1 Replies
acctcon(1M)															       acctcon(1M)

NAME
acctcon, acctcon1, acctcon2 - connect-time accounting SYNOPSIS
[options] [options] DESCRIPTION
The command converts a sequence of login/logoff records read from its standard input to a sequence of records, one per login session. Its input should normally be redirected from or Its output is ASCII, giving device, user ID, login name, prime connect time (seconds), non- prime connect time (seconds), session starting time (numeric), and starting date and time. Prime connect time is defined as the connect time within a specific prime period on a non-holiday weekday (Monday through Friday). The starting and ending time of the prime period and the year's holidays are defined in file expects as input a sequence of login session records, produced by and converts them into total accounting records (see format in acct(4)). combines the functionality of and into one program. It takes the same input format as and writes the same output as recognizes the following options: Print input only, showing line name, login name, and time (in both numeric and date/time formats). maintains a list of lines on which users are logged in. When it reaches the end of its input, it emits a session record for each line that still appears to be active. It normally assumes that its input is a current file, so that it uses the current time as the ending time for each ses- sion still in progress. The flag causes it to use, instead, the last time found in its input, thus ensuring reason- able and repeatable numbers for non-current files. and recognize the following options: file is created to contain a summary of line usage showing line name, number of minutes used, percentage of total elapsed time used, number of sessions charged, number of logins, and number of logoffs. This file helps track line usage, identify bad lines, and find software and hardware oddities. Hang-up, termination of (see login(1)), and termination of the login shell each generate logoff records, so that the number of logoffs is often three to four times the num- ber of sessions. See init(1M) and utmp(4). file is filled with an overall record for the accounting period, giving starting time, ending time, number of reboots, and number of date changes. When this option is used, the records of the type found in are read from the specified input. EXAMPLES
These commands are typically used as shown below. The file is created only for the use of commands described by the acctprc(1M) manual entry: or With option: or Note: The file can be either or a file containing records of the type found in WARNINGS
The line usage report is confused by date changes. Use (see fwtmp(1M)) to correct this situation. FILES
SEE ALSO
login(1), acct(1M), acctcms(1M), acctcom(1M), acctmerg(1M), acctprc(1M), acctsh(1M), fwtmp(1M), init(1M), utmpd(1M), runacct(1M), acct(2), getbwent(3C), acct(4), utmp(4). STANDARDS CONFORMANCE
acctcon(1M)
All times are GMT -4. The time now is 07:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy