-1

I would like to dupliacte lines in a folder with multiples txt files, including the blank lines. A batch command would be ideal or python drag&drop script. Here is an example. (x being blank line)

Alfred
x
Britney

And I need it like this.

Alfred
Alfred
x
x
Britney
Britney

As you can see, each line is doubled even the lines where there are no texts. How can that be done please ?

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
foubou
  • 1
  • 1

1 Answers1

0

I don't know about any ready made "batch command", but existing (Unix) tools can be used easily, e.g. sed

sed -e p /path/to/text/file.txt

or maybe awk

awk '{print; print;}' /path/to/text/file.txt

or Python (I'm no Python expert :-)

import fileinput
for line in fileinput.input():
    print(line.rstrip())
    print(line.rstrip())
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198