Thanks to Perderabo and Crashburn for this idea...
we need to add 1 so that we genrate line numbers between 1 to $nlines and not 0 to $nlines -1
or this should also work... here I'm ensuring by dividing with 32768 that the "random" number generated will fall within the no of lines that file contains.
On hp-ux 10, 11 we have man ksh giving
0 <= $RANDOM <= 32767
you can see the range for RANDOM by referring "man ksh" for your implementation...
My problem is as follow and i hope you can help:
I currently have this function:
stored_word()
{
number=$RANDOM
let "number %= 21"
case $number in
0 ) echo "energy" ;; 1 ) echo "touch" ;;
2 ) echo "climbing" ;; 3 ) echo "declare" ;;
4 ) echo "marry" ;; 5 ) echo "relax" ... (8 Replies)
I need to use the $RANDOM command to get a line from a list of lines in a file randomly.
file is
help
go
three
house
film
how do i randomly get one word without looking into the file? (6 Replies)
I have a text file with hundreds of lines, i wish to run a script and reads a random line to pass it to another command line such as:
for line in `cat file |grep random line`; do echo $line |mail my@example.com ; done
thank you (6 Replies)
Hi
I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue:
I want expect script for random passwords and random commands generation.
please can anyone help me?
Many Thanks in advance (0 Replies)
Hi experts,
My csv file looks like this
U;cake;michael;temp;;;;
U;bread;john;temp;;;;
U;cocktails;sarah;temp;;;;
I'd like to change the value fo 2nd column to cf+random number , which will look maybe something like this
U;cf20187;michael;temp;;;;
U;cf8926;john;temp;;;;... (7 Replies)
I have a file that needs to be parsed into multiple files every time there line contains a number 1. the problem i face is the lines are random and the file size is random. an example is that on line 4, 65, 187, 202 & 209 are number 1's so there has to be file breaks between all those to create 4... (6 Replies)
Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom.
I create a named pipe then:
dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024
but when I cat a file to the fifo that's 1024 random bytes:
cat randomfile.txt >... (7 Replies)
Hello
I created 3 files by:
dd if=/dev/urandom bs=1024 count=1000000 of=./testfile1
dd if=/dev/urandom bs=1024 count=5000000 of=./testfile2
dd if=/dev/urandom bs=1024 count=10000000 of=./testfile3
Now I want to know how to make a change in a specific byte and/or line of theses files? (2 Replies)
I have a file contains thousands of lines. I want to insert n random numbers into each line at
specific position. Like this:
0 22……
1 33……
……
……
I want to insert 3 random numbers from position 2 to 4 into each line.
0 325 22……
1 685 33……
……
……
Please use CODE tags when... (8 Replies)