bash question
Derek D. Martin
ddm+gnhlug at pizzashack.org
Mon Sep 23 14:06:03 EDT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At some point hitherto, Thomas M. Albright hath spake thusly:
> If the due date is greater than today, it outputs the message "Due in x
> days." If the due date is less than today I get a message saying "You
> are -x days past due." How can I convert the negative number into a
> positive one in bash?
var=`echo $var | sed 's/-//'`
or
# this is portable, but not as efficient as bash math
if [ $var -lt 0 ]; then
var=`expr 0 - $var`
fi
- --
Derek Martin ddm at pizzashack.org
- ---------------------------------------------
I prefer mail encrypted with PGP/GPG!
GnuPG Key ID: 0x81CFE75D
Retrieve my public key at http://pgp.mit.edu
Learn more about it at http://www.gnupg.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9j1gLdjdlQoHP510RAgKrAKCAzvEpQ7bIhgDAhNeraF79XObtwACcDeHM
15PQIaIFgyGA1vbbhyZU79c=
=hjsI
-----END PGP SIGNATURE-----
More information about the gnhlug-discuss
mailing list