SHUFFLE(1) BSD General Commands Manual SHUFFLE(1)NAME
shuffle -- print a random permutation of the command line arguments
shuffle [-0] [-f filename ...] [-n number] [-p number] [arg] [...]
The shuffle program prints a random permutation (or ``shuffle'') of its command line arguments. This can be useful in shell scripts for
selecting a random order in which to do a set of tasks, view a set of files, etc.
If the -f option is given, the data is taken from that files' contents or if the filename is - ``stdin''.
If the -n option is given, its argument is treated as a number, and the program prints a random permutation of the numbers greater than or
equal to 0 and less than the argument.
If the -p option is given, its argument is treated as a number, and the program prints that number of randomly selected lines or arguments in
a random order.
The -0 option changes the field separator character from
to , so that the output is suitable to be sent to xargs(1) (to handle filenames
with whitespace in them).
$ shuffle a b c d
$ shuffle -p 1 a b c d
$ shuffle -n 4 -p 2
SEE ALSO jot(1), random(6)HISTORY
The shuffle program first appeared in NetBSD 1.4.
Written by Perry E. Metzger <firstname.lastname@example.org>.
BSD February 18, 2009 BSD
Check Out this Related Man Page
RANDOM(6) BSD Games Manual RANDOM(6)NAME
random -- random lines from a file or random numbers
random [-elrUuw] [-f filename] [denominator]
Random has two distinct modes of operations. The default is to read in lines from the standard input and randomly write them out to the
standard output with a probability of 1 / denominator. The default denominator for this mode of operation is 2, giving each line a 50/50
chance of being displayed.
The second mode of operation is to read in a file from filename and randomize the contents of the file and send it back out to standard out-
put. The contents can be randomized based off of newlines or based off of space characters as determined by isspace(3). The default
denominator for this mode of operation is 1, which gives each line a chance to be displayed, but in a random(3) order.
The options are as follows:
-e If the -e option is specified, random does not read or write anything, and simply exits with a random exit value of 0 to denominator
- 1, inclusive.
The -f option is used to specify the filename to read from. Standard input is used if filename is set to '-'.
-l Randomize the input via newlines (the default).
-r The -r option guarantees that the output is unbuffered.
-U Tells random(6) that it is okay for it to reuse any given line or word when creating a randomized output.
-u Tells random(6) not to select the same line or word from a file more than once (the default). This does not guarantee uniqueness if
there are two of the same tokens from the input, but it does prevent selecting the same token more than once.
-w Randomize words separated by isspace(3) instead of newlines.
SEE ALSO random(3), fortune(6)HISTORY
The functionality to randomizing lines and words was added in 2003 by Sean Chittenden <seanc@FreeBSD.org>.
No index is used when printing out tokens from the list which makes it rather slow for large files (10MB+). For smaller files, however, it
should still be quite fast and efficient.
BSD February 8, 2003 BSD
I am trying to build a script written in ksh93 that pulls a random line out of each of four text files.
Since the files are all different, I can't think of a way to take the number of lines (in one case, let's say 50), then randomly pick a line out, making sure that all lines have a fair... (8 Replies)
hi, i have a large text file that I just want to extract the important
information from. It will be a random number of lines but between two specific
I was thinking I could get the line number for the first marker:
Tablespace Percent Total Free
Then get the line... (11 Replies)
I made a program that prints dots and lines in a Page. So far that's all i could come up with.
When i try to print the lines and the dots it just prints consecutive points,I want it to print the points & lines in the page's coordinates.
I have been stuck for a long time now. Please Help.
... (12 Replies)
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)
Hi there folks,
for an exercise for my pupils (you know i am always thinking of them!) i need to randomly re-arrange the words (blank space separated) in a sentence (a line in a textfile). Any inspiration??
Txk so much. (9 Replies)
I am in a terrible emergency. I have multiple cdr files with line count >6000.
I need to append |0| | | | | | | |random| to end of each line. The random number should never repeat.
Please help with a shell script to process all cdr's in a directory with above requirement. (23 Replies)
I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be:
SRVXPAPI001 ERRO JUN24 07:28:34 1775
REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F
... (8 Replies)
I have a list in the format below, how do I read through the list and extract the lines between the ##START## and ##END##, so i can check for specific values between each ##START## & ##END## pattern
sdfsdf... (10 Replies)
I have a file contains thousands of lines. I want to insert n random numbers into each line at
specific position. Like this:
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)
I was wondering if you could help as I'm sure its possible. I can remember something was possible using sed/awk a while back.
I have a list in a file such as sample_list.txt which contains the following:
example4, answer4... (13 Replies)
Hi Guys and gals...
As you know I am getting to grips with POSIX and hit this stumbling block.
Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command.
I have done a demo that works, but it sure is ugly! Is there a better way?
# Random... (12 Replies)
I'd like to put paragraph breaks \n\n randomly between 5 - 10 occurrences of the dot character (.), for an entire text file. How to do that?
In other words, anywhere between every 5 -10 sentences, a new paragraph will generate. There are no other uses of the (.) except for sentence breaks in... (11 Replies)
I'm struggling to understand the man page entry about xargs in conjunction with the option -I. It states:
And the description reads:
Am I correct interpreting that as the fact that if no specified otherwise xargs -I can pass to a command following it no more than 5 arguments (a.k.a... (10 Replies)
I have some video files containing numbers and characters . To tell the problem shortly, due to a limitation, I am unable create a playlist regularly changing on a daily basis with the command shuffle....So I decided to rename filenames, just a replacement of first five numbers randomly.... (10 Replies)