I have a file and its content looks like this:a1b1c1aabbccaaabbbcccd1e1f1ddeeffdddeeefffg1h1i1gghhiiggghhhiiiWhat's the best way to merge the rows with fixed interval (3 in this case) and get something like:a1 aa aaab1 bb bbbc1 cc cccd1 dd ddde1 ee eeef1 ff fffg1 gg gggh1 hh hhhi1 ii iiiThe algorithm to get the out put from the input is:First we get row 1 which is a1.We know the interval is 3So row 1, row (1+3), row (1+3+3) should be on the same rowSimilarly, row 2, 5, 8 should be on the same row etc.Those a1, aa and aaa etc. are just random dummy text and they could be any random string. The point is that there is a fixed interval between a1, aa and aaa. Currently I use emacs keyboard macro to do this task. However I want to know if there are any better ways to solve this problem. Thanks in advance. 
How to merge lines with fixed interval in a file?
text processing
If you're on gnu/anything and the number of lines is multiple of 9, you could runsplit -l9 --filter='pr -3 -s  -t' infileThis splits the input into pieces of nine lines and each piece is piped to pr -3 -s  -t' which columnates it... Depending on the no. of lines and their length you may need to play with pr options -w and -l. See the man page for more details.