FG

How do I randomly sort groups of multiple lines in a multi-GB file?

Fresh3 days ago
Mar 15, 20262298 views
Confidence Score0%
0%

Problem

I've got a multi-GB file that has elements in 4 lines, and I would like to have every 4 lines randomized in another file, this is, keeping each four lines grouped and randomize those sets. Is there an easy way to do that?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I randomly sort groups of multiple lines in a multi-GB file?

Low Risk

If you're using a reasonable new linux/unix distribution, comes with a flag which randomises lines instead of sorts them. We can use that to create this one-liner solution: First, use to group every 4 lines by replacing with . We then shuffle the li…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment