[Novalug] Bash math help?
Steve Green
steve_green1@msn.com
Sun Apr 1 21:18:37 EDT 2012
Nick,
You need to add command separators ";" after your variable definitions,
that's all, like this.
[nbrenckle@smtp-cm perl]$ oldfilelines=17005; newfilelines=17003; echo
"$oldfilelines/$newfilelines" | bc -l
v/r,
Steve
-----Original Message-----
From: Nick Danger
Sent: Sunday, April 01, 2012 8:53 PM
To: NOVALUG
Subject: [Novalug] Bash math help?
Ok, whats wrong with this?
[nbrenckle@smtp-cm perl]$ oldfilelines=17005 newfilelines=17003 echo
"$oldfilelines/$newfilelines" | bc -l
(standard_in) 1: parse error
[nbrenckle@smtp-cm perl]$ echo "17005/17003" | bc -l
1.00011762630124095747
[nbrenckle@smtp-cm perl]$
I need to do some quick percentage in a shell script. Int is fine, I
don't need precision, just want a rough idea of how much a file has
changed between runs. Script bombs out with the error above, so I tried
to run it just on the command line. Same error. Is it how I am echoing
the variables?
Nick
_______________________________________________
Novalug mailing list
Novalug@calypso.tux.org
http://calypso.tux.org/mailman/listinfo/novalug
More information about the Novalug
mailing list