simple bash script problem with division.
Hi all. This is a simple bash script that i've spent way too much time on, I'm tying to get a few stats from a group of files. Basically there is a group of files per day (i.e. today = 20081031-0.txt to 20081031-9.txt) and they vary, but I want to check these logs to see how many times we are hitting a .com, .net, etc.. The "percent" is where I'm having issues... It's not really a big deal, but I figured I'd post it. This will be run on FreeBSD btw, if it matters.
Thanks in advance!
If you want fraction then use "bc":
percent=`echo $count*100/$total | bc -l`
bash's internal maths can't do floating point calculations; you're best off using bc, which can to a specified number of digits.
edit: too slow by half! :)
|All times are GMT -5. The time now is 07:16 AM.|