Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Modulus Operator, Simple Shell Script
etangman
post Jun 12 2008, 06:55 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 12-June 08
Member No.: 13,504



Alright, I am attempting to add records to a database, but I need them to be divisible by 30 so that I can update them concurrently.
In order to do this I intended to use `date +%s` to get the current time in seconds, and then add 1 until the number was divisible by 30.
To simplify things I made $now equal to a number I knew was divisible by 30 for testing, but the modulus operator doesn't work.
I'm assuming my syntax is wrong, but everything I've looked at makes it look right to me. The increment operator wouldn't work either...
Any help would be much appreciated because I'm at a standstill with this nonsense. Thanks.

#now=`date +%s`
now=1213204110
tmp=0

if [ $now%30 != 0 ]
then
while [ $now%30 != 0 ]
do
tmp=`expr $now + 1`
now=$tmp
done
fi

echo $now
Go to the top of the page
 
+Quote Post

Posts in this topic
- etangman   Modulus Operator   Jun 12 2008, 06:55 AM
- - michaelk   Lots of help can be found on bash shell scripts by...   Jun 13 2008, 05:58 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th December 2017 - 04:21 AM