![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|