Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

may be this post helps you http://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-commandhttps://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-command

$ cat input.txt
a,b,c,d
a,b
a,b,c,d
a,b,c
a,b,c,d


$ awk -F, 'NF<4{cmd="echo output1";while(cmd|getline line){printf("%s,%s\n",$0,line)};close(cmd);next}1' input.txt
a,b,c,d
a,b,output1
a,b,c,d
a,b,c,output1
a,b,c,d

may be this post helps you http://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-command

$ cat input.txt
a,b,c,d
a,b
a,b,c,d
a,b,c
a,b,c,d


$ awk -F, 'NF<4{cmd="echo output1";while(cmd|getline line){printf("%s,%s\n",$0,line)};close(cmd);next}1' input.txt
a,b,c,d
a,b,output1
a,b,c,d
a,b,c,output1
a,b,c,d

may be this post helps you https://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-command

$ cat input.txt
a,b,c,d
a,b
a,b,c,d
a,b,c
a,b,c,d


$ awk -F, 'NF<4{cmd="echo output1";while(cmd|getline line){printf("%s,%s\n",$0,line)};close(cmd);next}1' input.txt
a,b,c,d
a,b,output1
a,b,c,d
a,b,c,output1
a,b,c,d
Source Link
Kamaraj
  • 4.4k
  • 1
  • 15
  • 19

may be this post helps you http://stackoverflow.com/questions/20646819/how-can-i-pass-variables-from-awk-to-a-shell-command

$ cat input.txt
a,b,c,d
a,b
a,b,c,d
a,b,c
a,b,c,d


$ awk -F, 'NF<4{cmd="echo output1";while(cmd|getline line){printf("%s,%s\n",$0,line)};close(cmd);next}1' input.txt
a,b,c,d
a,b,output1
a,b,c,d
a,b,c,output1
a,b,c,d