I have some files, say a, b, c, I would like something like
> cat a b c
but with "a" at the beginning of line a. "b" at the beginning of lines b and "c" at the beginning of lines c. I can do it with python:
#!/bin/env python
files = 'a b c'
all_lines = []
for f in files.split():
lines = open(f, 'r').readlines()
for line in lines:
all_lines.append(f + ',' + line.strip())
fout = open('out.csv', 'w')
fout.write('\n'.join(all_lines))
fout.close()
but I would prefer to do this on the command line by combining some simple commands with the channel | Operator.
Is there an easy way to do this?
Thank.
source
share