hi,
I need a command which picks the records randomly from the file.
For example. i am having some 10000 entries in a file and need to extract the lines randomly without repeating the numbers.
Do anybody have any idea on how to get this out.
hi,
I need a command which picks the records randomly from the file.
For example. i am having some 10000 entries in a file and need to extract the lines randomly without repeating the numbers.
Do anybody have any idea on how to get this out.
#!/bin/bash
RANGE=1000
number=$RANDOM
let "number %= $RANGE"
echo "Random number less than $RANGE --- $number"
Alternative , in Python:
>>> import random
>>> length = 10000
>>> all = open("file_with_records.txt").readlines()
>>> for num in range(0,length-1):
... randnum = random.randint(0,length-1) #generate random num
... print all[randnum]
#!/usr/bin/perl
use strict;
my $limit = 10000;
my $random_number = int (rand $limit);
print "random number: $random_number \n";
Thanks a lot,
This is working now