Questions tagged [shuf]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
5answers
77 views

Can a shell script find all groups of consecutive lines matching the same regex and shuffle them?

I'm writing quizzes for my students in a markdown language. One of the quizzes might look like this: % QUESTION Who played drums for The Beatles? (X) Ringo ( ) John ( ) Paul ( ) George % QUESTION ...
0
votes
2answers
170 views

How to sample without replacement from a script that randomly extracts 200characters using shuf?

I have this script that extracts 200 random characters from a set: #!/usr/bin/bash n=$(stat -c "%s" newfile.txt) r=$(shuf -i1-"$((n-200+1))" -n1) < newfile.txt tail -c+"$r&...
0
votes
1answer
81 views

How to replace Shuf with rand (from C++) with a seed of time in order to make my script more random [closed]

I have this script that extracts 200 random characters from a set: tail -n+2 file.fasta | tr -d '\n' > newfile n=$(stat -c "%s" newfile) r=$(shuf -i1-"$((n-200+1))" -n1) newfile ...
0
votes
1answer
57 views

Write all numbers between 0 and large number (both inclusive) to a file in random order

For simulation I am trying to do, I want a text file with numbers ranging from 0 to 2^33 which is a huge number. I have used this command: seq 0 Number >> OUTPUT FILE But this is very slow. ...
2
votes
0answers
131 views

shuffle two parallel text files not giving same lines even if same random source

This is similar to Shuffle two parallel text files I have: two large csv files with parallel lines. (they represent 'before' and 'after' states for particular items). The fields are sometimes ...
0
votes
4answers
5k views

How to pick a random file from a folder without repetition using bash?

I can select a random file using this command find ./ -type f | shuf -n 1 But it's showing the same file some times. Is it possible to stop picking duplicate files? Is there any other utility for ...
0
votes
2answers
214 views

Piping Output of Shuf Command [duplicate]

Fairly new to Linux. I have a nixie clock that runs off of a Raspberry Pi. I would like to send a random sequence of six digits to it every so often to help prolong the life of the Nixie tubes. ...
3
votes
1answer
330 views

What does shuf -e means in bash

I have string save as test="test1 test2 test3 test4 test5 test6" and echo $(shuf -e $test) it gives me the same output as $test, why? I expect the different order of the original string
2
votes
2answers
715 views

Does the size of the random_source file matter?

Some GNU coreutils utilities like sort and shuf use a file as what effectively serves a seed. Does the size of the file matter? The recommended way, https://www.gnu.org/software/coreutils/manual/...
0
votes
0answers
114 views

Is this segment fault raised when running `shuf`?

I have a script, where there is a line: eval for i in \{"$1".."$2"\}\; do [ ! -e "$3"/\$i.\* ] \&\& echo \"\$i\" \; done \| shuf \| mycommand "$3" which means: first create a sequence of ...
3
votes
1answer
2k views

Moving random files using shuf and mv - Argument list too long

I have a directory containing nearly 250K files, which are lots of files, and I want to move x random files to another directory. I searched and I got the solution of using the shuf and mv commands ...
0
votes
1answer
356 views

How to select random sample of n lines from each file in a directory

I have a directory with many files. From each of these files I want a random sample and copy to a new directory with file names same as from which random sample was drawn.
2
votes
2answers
302 views

Randomly select a line in every block of N lines [duplicate]

I'd like to randomly select a line after a given number of lines. For example here's my input: 8 blue 8 red 8 yellow 8 orange 3 pink 3 white 3 cyan 3 purple 1 magenta 1 black 1 green 1 brown and ...