In awk, the rand() function is seeded with the actual system epoch time, and srand() "returns the value of the previous seed" (c.f. man awk). No need to supply an external datetimestamp. Try this
Hi all,
I've a shell script which runs on Bourne shell. I've to do a date comparison. If the value of the supplied parameter(in format YYYYMMDD)is greater than todays's date(format YYYYMMDD), it should prompt the user that the supplied date is greater than today's date. The script is given... (6 Replies)
Hi
I have this simple script:
#!/bin/bash
date1=2009:07:15:12:36
date2=2009:07:15:12:16
echo $date1
echo $date2
datediff=
#datediff=date1-date2
echo datediff is$datediff
How do i return the difference in seconds? (6 Replies)
1. The problem statement, all variables and given/known data:
I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format .
I have developed a log analysis command line utility that displays... (1 Reply)
Date comparison
Hello all
I am writing a scrip that will take action so long as the date with in the file is older than 3 months. The file will contain multiple rows of data. Each row will probably start with the date. My question... What is the exact code that should be used for date... (1 Reply)
Hi friends,
I would like to compare two dates in an IF statement.
This is what I am trying, but it doesn't work.
date=20120122
minus=6
if ; then
...
fi
what would the IF clause looks like?
Thanks! :) (5 Replies)
hi,
I have a file named user.cfg under /var/member/
#user.cfg file under /var/member/
login user: root #how are you
login pass: admin #where are you
M: user1 pass1 #20121008
M: user2 pass2 #20111230
M: user3 pass3 #20091220
M: user4 pass4 #20070210
M: user5 pass5 #20130708
M:... (3 Replies)
Hi
Need some function or step to compare the date as given below.
Example:
Date_1: 25/04/2013
Date_2: 20/07/2012
if Date_1 is greater than Date_2 then
do...
else
do..
fi
Need exact unix steps to compare the above condition
Use code tags please, see PM. (5 Replies)
I have below txt file
02.05.2014
10.05.2014
17.09.2014
My requirement is the user enter date field should compare the input file
if user enter date as 12.03.2013 it should compare with all date one by one from input file
12.03.2013 -ne 02.05.2014
12.03.2013 -ne 10.05.2014... (3 Replies)
Discussion started by: stew
3 Replies
LEARN ABOUT SUSE
srand
RAND(3) Linux Programmer's Manual RAND(3)NAME
rand, rand_r, srand - pseudo-random number generator
SYNOPSIS
#include <stdlib.h>
int rand(void);
int rand_r(unsigned int *seedp);
void srand(unsigned int seed);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
rand_r(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
DESCRIPTION
The rand() function returns a pseudo-random integer in the range [0, RAND_MAX].
The srand() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by rand(). These sequences
are repeatable by calling srand() with the same seed value.
If no seed value is provided, the rand() function is automatically seeded with a value of 1.
The function rand() is not reentrant or thread-safe, since it uses hidden state that is modified on each call. This might just be the seed
value to be used by the next call, or it might be something more elaborate. In order to get reproducible behavior in a threaded applica-
tion, this state must be made explicit. The function rand_r() is supplied with a pointer to an unsigned int, to be used as state. This is
a very small amount of state, so this function will be a weak pseudo-random generator. Try drand48_r(3) instead.
RETURN VALUE
The rand() and rand_r() functions return a value between 0 and RAND_MAX. The srand() function returns no value.
CONFORMING TO
The functions rand() and srand() conform to SVr4, 4.3BSD, C89, C99, POSIX.1-2001. The function rand_r() is from POSIX.1-2001.
POSIX.1-2008 marks rand_r() as obsolete.
NOTES
The versions of rand() and srand() in the Linux C Library use the same random number generator as random(3) and srandom(3), so the lower-
order bits should be as random as the higher-order bits. However, on older rand() implementations, and on current implementations on dif-
ferent systems, the lower-order bits are much less random than the higher-order bits. Do not use this function in applications intended to
be portable when good randomness is needed. (Use random(3) instead.)
EXAMPLE
POSIX.1-2001 gives the following example of an implementation of rand() and srand(), possibly useful when one needs the same sequence on
two different machines.
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(void) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768);
}
void mysrand(unsigned seed) {
next = seed;
}
SEE ALSO drand48(3), random(3)COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
2008-08-29 RAND(3)