Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to convert
1
2
3
4
5
6
7
8
9into
123
456
789I've seen examples with awk using a[something]=a[something] but I can't make it work. Can anyone help please?

One way is to use awk's modulo operator:
#!/bin/bash
awk ' { if(NR % 3 == 0 ) printf("%s\n", $0) else printf("%s", $0) } ' datafile.txt

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |