Terminal command equivalent of PHP implode when combining lines

后端 未结 5 1991
不知归路
不知归路 2020-12-21 07:40

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          


        
5条回答
  •  情歌与酒
    2020-12-21 08:14

    seq 16 |awk '{printf NR%5 ? (NR % 5 ==1 ? $0 : ","$0) : ","$0"\n";}'
    #output:
    1,2,3,4,5
    6,7,8,9,10
    11,12,13,14,15
    16
    

提交回复
热议问题