How to delete a specific amount of columns randomly?

61 Views Asked by At

Using this range from 1 to 60, formatted in 6 lines and 10 columns.

01 02 03 04 05 06 07 08 09 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60

The command

awk -v n=6 -v p=2 ' BEGIN {srand()} rand() * n-- < p {p--; next} {print}' < file

deletes 2 lines of the 6 existing lines randomly.

How can I do the same with the columns? Delete a specific amount of columns randomly, (using awk, preferably).

Example:

Delete 3 (or any number from 1 to 10) from any of the 10 columns.

0

There are 0 best solutions below