Skip to content

Instantly share code, notes, and snippets.

@RodrigoDornelles
Last active January 12, 2021 15:25
Show Gist options
  • Save RodrigoDornelles/2835550e52e6fc7513e9356e861d8991 to your computer and use it in GitHub Desktop.
Save RodrigoDornelles/2835550e52e6fc7513e9356e861d8991 to your computer and use it in GitHub Desktop.
concatenate two files line by line using a simple python script.
import sys, itertools
try:
file1, file2 = open(sys.argv[1], 'r').readlines(), open(sys.argv[2], 'r').readlines()
[sys.stdout.write(l1.replace('\n', '') + l2.replace('\n', '')) for (l1,l2) in itertools.zip_longest(file1, file2, fillvalue='')]
except:
sys.stderr.write('[!] Error: require two valid files!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment