Skip to main content
1 of 2
iruvar
  • 17k
  • 8
  • 51
  • 81

It would appear that you're looking to cycle through the contents of the smaller file

With awk

awk 'NR == FNR{a[++i]=$0; next}; {print $0, a[FNR % i? FNR % i: i]}' smaller_file larger_file 

And python

from itertools import cycle, izip with open('file1') as f1, open('file2') as f2: z = izip(f1, cycle(f2)) for l, m in z: print l.rstrip('\n'), m.rstrip('\n') 
iruvar
  • 17k
  • 8
  • 51
  • 81