Friday, January 20, 2017

Minimal Perl code to generate 32 characters alphanumeric random string.

This code generates a random 32 characters string.

use v5.22;
print join '', map {state $c = ['a'..'z', 'A'..'Z', '0'..'9']; $$c[rand @$c]} 0..31;

Output (6 runs):

NUPtwWIRTDOTmoBZ2xgDtceHjvjUloAi
7rKd8024tNZdgCUJJjlrQlBqKh53lpUV
dSPKG8uODbriqmbtEFDvrypbrx22BhuO
A5ozpCeKTCY322otKSlhiAcOV4E8LwZS
DTKcTiUJ7xGFO3kR6Tmh29J5rT88jBoJ
y7Q7VeCY7q83P7c2D2JK9C8svy59efXw

Tuesday, January 3, 2017

Printing column data one by one - awk

Suppose you have a file like this:



You need to get this output:


, you can use this awk code: