Hallo to everyone!
I would like to merge lines of a huge file into a formatted one. Be the following file (it has 1.9GB) called `input.txt':
Code:
2
3
5
7
11
13
17
19
23
29
...
3999999797
3999999799
3999999869
3999999881
3999999901
3999999911
3999999919
3999999937
3999999979
I would like to get (output.txt):
Code:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, (...) 3999999797, 3999999799, 3999999869, 3999999881, 3999999901, 3999999911, 3999999919, 3999999937,
3999999979.
Well, I have already tried the following commands:
Code:
$ sed -e :a -e N -e 's/\n/, /' -e ta input.txt > output.txt
It fails because there is no memory enough to complete the operation since the sed buffer uses the memory.
Code:
$ paste -s -d "," input.txt > output.txt
It almost works, but it misses the space required for formatting.
Code:
$ paste -s -d "," input.txt | sed "s/,/, /g" > output.txt
Same problem that first option tried.
Code:
$ tr -t "," ", " < input.txt > output.txt
It does not substitute one character `,' by two ", "
- Does anyone have one or more solution for this problem?
Thanks in advance.
[]s