vendredi 18 mars 2016

Change the nth character to a Random character in Linux

i have a text file with a list of numbers. I would like to change the 11th character to a random number. input.txt
00018674395618674395
00018674396618674396
00018674397618674397
00018674398618674398
00018674399618674399
00018674400618674400

 sed 's/^\(.\{11\}\)./\1'$(((RANDOM % 10)+1))'/' input.txt > output.txt

However, this just generates a random number and inserts it as the 11th character, so the 11th number becomes for example 4 in every-line. I would like a random number in each line 00018674395618674395
00018674396318674396
00018674397518674397
00018674398718674398
00018674399718674399
00018674400218674400

thanks in advance




Aucun commentaire:

Enregistrer un commentaire