The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Output in my shell isn't showing properly. satyakide Shell Programming and Scripting 7 04-01-2008 10:05 AM
divide issue kotasateesh UNIX for Dummies Questions & Answers 1 02-13-2008 02:43 AM
Shell script not processing if statement properly jonathan184 Shell Programming and Scripting 2 05-08-2007 03:24 PM
divide with awk tontal Shell Programming and Scripting 1 10-09-2006 07:23 AM
script needs to divide by 2 wereyou Shell Programming and Scripting 2 09-26-2006 07:42 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-26-2008
mikez104 mikez104 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
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...
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0