[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-----
I think it's simpler than that - this little scriptlet sounds like it
might do what you're asking for.
declare -i in
declare -i out
((in = 0))
((out = 0))
while read direction amount; do
if [ "$direction" == "i" ];then
((in += $amount))
((out += $amount))
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 v18.104.22.168 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the LUG