Are all the records the same length? In your sample data they all appear to be 216 characters long.
If so you might be able to use this perl program, it takes 1 argument which is the name of your input file and outputs the random shuffle of the records.
Code:
#!/usr/bin/perl
my $rsz = 216;
my $fsize = -s $ARGV[0];
my $record;
my @recs = (0..($fsize/$rsz)-1);
fisher_yates_shuffle(\@recs);
open(fp, $ARGV[0]) || die;
for (my $c = 0; $c < $#recs; $c++ ) {
seek(fp, $recs[$c]*$rsz, 0);
read(fp, $record, $rsz);
print $record;
}
close(fp);
sub fisher_yates_shuffle {
my $array = shift;
my $i;
for ($i = @$array; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}
Last edited by Chubler_XL; 05-23-2013 at 06:38 AM..
Hi,
Is there a tool somewhat parallel to rev, but which randomizes instead of reverses?
I've tried rl, but I can only get it to randomize words.
I was hoping for something like this
echo "hello" | ran
leolh
less simpler solutions are also welcome.
Sorry if the question is... (21 Replies)
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
--please have a look at my third post in this thread! there I explained it more clearly--
Hey guys.
I posted a complex problem few days back. No reply! :|
Here is simplified question:
I have a matrix with 0/1:
* col1 col2 col3
row1 1 0 1
row2 0 0 ... (5 Replies)
Hi,
I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file.
File1 - file2 = file3
wc -l file1.txt
58112
wc -l file2.txt
55260
head -5 file1.txt
101214200123
101214700300
101250030067
101214100500... (10 Replies)
Hi there, friends!
Writing exams again! This time my wish would be to randomize certain columns in a csv file. Given a file containing records consisting of 3 columns tab-separated:
A B C
A B C
A B C
I would love to get the columns of each record in random order...separated by a tab as... (12 Replies)
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
LEARN ABOUT PHP
dbase_add_record
DBASE_ADD_RECORD(3) 1 DBASE_ADD_RECORD(3)dbase_add_record - Adds a record to a databaseSYNOPSIS
bool dbase_add_record (int $dbase_identifier, array $record)
DESCRIPTION
Adds the given data to the database.
PARAMETERS
o $dbase_identifier
- The database link identifier, returned by dbase_open(3) or dbase_create(3).
o $record
- An indexed array of data. The number of items must be equal to the number of fields in the database, otherwise
dbase_add_record(3) will fail.
Note
If you're using dbase_get_record(3) return value for this parameter, remember to reset the key named deleted.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Inserting a record in a dBase database
<?php
// open in read-write mode
$db = dbase_open('/tmp/test.dbf', 2);
if ($db) {
dbase_add_record($db, array(
date('Ymd'),
'Maxim Topolov',
'23',
'max@example.com',
'T'));
dbase_close($db);
}
?>
SEE ALSO dbase_delete_record(3), dbase_replace_record(3).
PHP Documentation Group DBASE_ADD_RECORD(3)