[lug] Bash-ing an FTP log summary
Kenneth D. Weinert
kenw at quarter-flash.com
Wed Jun 28 06:50:19 MDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I think it's simpler than that - this little scriptlet sounds like it
might do what you're asking for.
#!/bin/bash
declare -i in
declare -i out
((in = 0))
((out = 0))
while read direction amount; do
if [ "$direction" == "i" ];then
((in += $amount))
else
((out += $amount))
fi
done
echo "Input: $in"
echo "Output: $out"
and run it like:
scriptname < datafile
Bill Thoen wrote:
> Thanks... I'll try that. Both methods are new to me, but I should be able
> to figure out the syntax once I know what to look for!
>
> - Bill Thoen
>
>
> On Tue, Jun 27, 2006 at 08:24:56PM -0600, Tony Dyson wrote:
>> First thought is that "cut" & a "for i in `cat <tmp-file>`; do
>> [etcetera]" might help you to get the numerical component into a
>> variable for further manipulation.
>>
>> Bill Thoen wrote:
>>> Hi folks,
>>>
>>> I'm trying to write a bash script to summarize total daily FTP transfers
>>> (in terms of data transfered in and out) from my vsftp logs. So far, I've
>>> got a file
>>> that produces output like this each day:
>>>
>>> o 123456
>>> o 32456
>>> i 1235
>>> o 123456
>>> ... etc.
>>>
>>> The 'o' is out and 'i' is in. The number is the amount transfered. What I
>>> want to do is summarize the transfers each day and add them to a running
>>> total in a file. Can I do this in a bash script? How?
>> _______________________________________________
>> Web Page: http://lug.boulder.co.us
>> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEonsLue452eujrHIRAmWaAJ0UTNfGT+296fg6FBLXRAMOdGxNdACfbNhD
JE4iqNJVkZY+C4wOjeCR7OI=
=Tf9a
-----END PGP SIGNATURE-----
More information about the LUG
mailing list