Skip to main content
added 86 characters in body
Source Link
RomanPerekhrest
  • 30.8k
  • 5
  • 47
  • 68

With awk system() function:

Sample input.txt:

a
b
c

awk '{ 
         printf "name";
         system("tr -dc \047[:alnum:]\047 </dev/urandom | head -c6");
         printf "-%s\n", $0
     }' input.txt

Sample output:

nameSDbQ7T-a
nameAliHY0-b
nameDUGP2S-c

system(command)
Execute the operating system command command and then return to the awk program

https://www.gnu.org/software/gawk/manual/gawk.html#index-system_0028_0029-function

With awk system() function:

Sample input.txt:

a
b
c

awk '{ 
         printf "name";
         system("tr -dc \047[:alnum:]\047 </dev/urandom | head -c6");
         printf "-%s\n", $0
     }' input.txt

Sample output:

nameSDbQ7T-a
nameAliHY0-b
nameDUGP2S-c

With awk system() function:

Sample input.txt:

a
b
c

awk '{ 
         printf "name";
         system("tr -dc \047[:alnum:]\047 </dev/urandom | head -c6");
         printf "-%s\n", $0
     }' input.txt

Sample output:

nameSDbQ7T-a
nameAliHY0-b
nameDUGP2S-c

system(command)
Execute the operating system command command and then return to the awk program

https://www.gnu.org/software/gawk/manual/gawk.html#index-system_0028_0029-function

Source Link
RomanPerekhrest
  • 30.8k
  • 5
  • 47
  • 68

With awk system() function:

Sample input.txt:

a
b
c

awk '{ 
         printf "name";
         system("tr -dc \047[:alnum:]\047 </dev/urandom | head -c6");
         printf "-%s\n", $0
     }' input.txt

Sample output:

nameSDbQ7T-a
nameAliHY0-b
nameDUGP2S-c