I received a question about how to randomize column order in a text file. I came up with the method that using common Unix command line tools (sort
, sed
, tr
, join
) and the BASH shell. It has been tested on the BSD command line tools in macOS 12 (running zsh
) and gnu command line tools BASH on CentOS (running bash
).
NOTE: this does not handle quoted commas in the CSV. The only commas should be the delimiters.
NUM_COLS=10
NUM_RANDOMIZED_OUTPUT=5