Could someone help on how to write an bash script to generate a file named inputFile whose content looks like:
0, 334
1, 933
2, 34123
3, 123
These are comma separated values with index and a random number.
-> Running the script without any arguments, should generate the file inputFile with 10 such entries in current directory.
-> You should be able to extend this script to generate any number of entries, for example 100000 entries.
I tried below script but its not as expected, could someone help me to fix this?
RANDOM=$$
num=0
while [[ ${num} -le $1 ]]
do
echo $num $RANDOM
(( num = num +1 ))
done
RANDOM=$$. Fromman bash: RANDOM: Each time this parameter is referenced, it expands to a random integer between 0 and 32767$$(the shell's pid) is used as the seed of the sequence. At least it varies on each run. Bash Ref Manual does not say how RANDOM is initialised, but I found a post that claimed:gettimeofday (&tv, NULL);sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());