Sponsored Content
Top Forums Shell Programming and Scripting randomly shuffle two text files the same way Post 302551850 by Chubler_XL on Wednesday 31st of August 2011 10:34:08 PM
Old 08-31-2011
Another idea if your shuf supports --random-source

Code:
$ dd if=/dev/random of=myrand count=1024
 
$ shuf --random-source=myrand file1
one
three
five
four
two

$ shuf --random-source=myrand file2
1
3
5
4
2

This User Gave Thanks to Chubler_XL For This Post:
 

8 More Discussions You Might Find Interesting

1. AIX

Randomly appearing control characters in text files

Hi, From some time, we have noticed that our ascii files have started corrupting due to the presence of some random control characters (^@, ^M, ^H, ^D). The characters appear randomly on any file after the process that creates the file finishes. If we rerun the process, the files re creates... (0 Replies)
Discussion started by: aakashahuja
0 Replies

2. UNIX for Dummies Questions & Answers

randomly renaming files

I have a directory of files that look like filename 001.ext, filename 002.ext, etc. I'd like to rename the files with unique random numbered names, so that the original filenames are stripped and the files are given a new, random number name. I'm not super new to UNIX, but I don't often use it for... (2 Replies)
Discussion started by: platz
2 Replies

3. Shell Programming and Scripting

shuffle pack of words in line

hello i just seeking for a simple way to make a shuffle by block of words in a line. no matter shell (sh/bash) or perl should be like this: the message (which is line of some file) splits to packs (packs are random 5-10 words in each) then making a new line inserting those packs in a random... (9 Replies)
Discussion started by: tip78
9 Replies

4. UNIX for Dummies Questions & Answers

How to randomly select lines from a text file

I have a text file with 1000 lines, I want to randomly select 200 lines from it and print them as output. How do I go about doing that? Thanks! (7 Replies)
Discussion started by: evelibertine
7 Replies

5. Shell Programming and Scripting

Randomly selecting sequences and generating specific output files

I have two files containing hundreds of different sequences with the same Identifiers (ID-001, ID-002, etc.,), something like this: Infile1: ID-001 ATGGGAGCGGGGGCGTCTGCCTTGAGGGGAGAGAAGCTAGATACA ID-002 ATGGGAGCGGGGGCGTCTGTTTTGAGGGGAGAGAAGCTAGATACA ID-003... (18 Replies)
Discussion started by: Xterra
18 Replies

6. Shell Programming and Scripting

How to shuffle odd and even columns?

Is there any way to place each even column name infront of its odd column using awk or others? input Ab name MGH26 B04 MGH26 B05 output name_Ab B04_MGH26 B05_MGH26 (4 Replies)
Discussion started by: quincyjones
4 Replies

7. Shell Programming and Scripting

Randomized shuffle words on each line

Hi Folks, I have a text file with a thousand lines consisting of words or a group of words separated by commas. I would like to randomize / shuffle the words on each line. Eg; file.txt Linux,Open,Free,Awesome,Best Things in Life,The Greatest Laptop,PC,Tablet,Home Computers,Digital... (2 Replies)
Discussion started by: martinsmith
2 Replies

8. UNIX for Beginners Questions & Answers

Logic shuffle

Hi, Is there any way I can shuffle the numbers randomly. I have been trying to google and I found lots of 'generator' but is it possible to find the background logic to create randomness? Thanks, (3 Replies)
Discussion started by: Indra2011
3 Replies
autobox::List::Util(3pm)				User Contributed Perl Documentation				  autobox::List::Util(3pm)

NAME
autobox::List::Util - bring the List::Util functions to autobox VERSION
Version 20090629 SYNOPSIS
"autobox::List::Util" brings all of the functions from List::Util to arrays as methods. use autobox::List::Util; my @array = qw/ foo bar baz /; print @array->first(sub { /ar/ }), " "; # "bar" print [5, 6, 3, 4]->max, " "; # 6 print @array->maxstr, " "; # baz print [5, 6, 3, 4]->min, " "; # 3 print @array->minstr, " "; # foo print [1 .. 10]->shuffle, " "; #1 to 10 randomly shuffled print [1 .. 10]->sum, " "; # 55 print [1 .. 10]->reduce( sub { $a + $b } ), " "; # 55 METHODS
first(coderef) This method behaves nearly the same as the first function from List::Util, but it takes a coderef not a block because methods can't use prototypes. reduce(coderef) This method behaves nearly the same as the reduce function from List::Util, but it takes a coderef not a block for the same reason. It also has a bug (see BUGS) shuffle If called in scalar context it returns a reference to an array instead of a list. This allows shuffle to be chained with other calls. max, maxstr, min, minstr, sum These methods behave exactly the same as their List::Util counterparts. AUTHOR
Chas. J. Owens IV, "<chas.owens at gmail.com>" BUGS
The reduce method works with $main::a and $main::b, not your current package's $a and $b, so you need to say print @array->reduce( sub { $main::a + $main::b } ), " "; if you are not in the main package. Reduce uses $_, so it doesn't suffer from this problem. SUPPORT
You can find documentation for this module with the perldoc command. perldoc autobox::List::Util You can also look for information at: o RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=autobox-List-Util> o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/autobox-List-Util> o CPAN Ratings <http://cpanratings.perl.org/d/autobox-List-Util> o Search CPAN <http://search.cpan.org/dist/autobox-List-Util/> ACKNOWLEDGEMENTS
COPYRIGHT &; LICENSE Copyright 2009 Chas. J. Owens IV, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-04-17 autobox::List::Util(3pm)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy