I have a couple of lines and want to group the line into 5 and then implode it for MySQL IN ()
query.
I have made it out until this
awk
You can do:
awk 'NR%5==0{print s","$0; s=""; next} {if (length(s)>0){ s=s","$0 } else s=$0} END {print s}'
Test it:
$ seq 1 6 | awk 'NR%5==0{print s","$0; s=""; next} {if (length(s)>0){ s=s","$0 } else s=$0} END {print s}'
1,2,3,4,5
6
$ seq 1 12 | awk 'NR%5==0{print s","$0; s=""; next} {if (length(s)>0){ s=s","$0 } else s=$0} END {print s}'
1,2,3,4,5
6,7,8,9,10
11,12