1

Topic: Line end changeover on + an insertion of characters

Prompt as in Linux as fast as possible to make in the text file
1. Changeover \n on ', ' line ends can be a little \n\n\n and the comma is necessary one, right at the end the comma is not necessary
2. In the file beginning to thrust 1 character
3. In the file end to thrust 1 character
As a result
111111
222222
333333
It is necessary to alter in [11111,22222,33333]
We use only utilities from standard delivery, perl too fits
As fast as possible because files of ten gigabyte, lines in them tens megabytes

2

Re: Line end changeover on + an insertion of characters

Sintetik,  the decision on a C will be on determination faster.

3

Re: Line end changeover on + an insertion of characters

sed

4

Re: Line end changeover on + an insertion of characters

Scott Tiger wrote:

Sintetik,  the decision on a C will be on determination faster.

Probably, but to do there is nobody, therefore it is necessary to manage standard utilities

5

Re: Line end changeover on + an insertion of characters

Dimitry Sibiryakov wrote:

sed

I know that is possible for them, what expression?
Found sed ' s / ^, +//; s/, + $//; s/, +/,/g ' but not

6

Re: Line end changeover on + an insertion of characters

Sintetik wrote:

I know that is possible for them, what expression?

I was wrong, it line, to it does not turn out.

7

Re: Line end changeover on + an insertion of characters

Sintetik;
(and with perl too) http://linux-notes.org/poisk-i-zamena-s … lah-linux/

8

Re: Line end changeover on + an insertion of characters

Dimitry Sibiryakov wrote:

I was wrong, it line, to it does not turn out.

Well it is finite...
sed-r ':a; N; $! ba; s/\n +/,/g'

9

Re: Line end changeover on + an insertion of characters

Still is paste-s-d

10

Re: Line end changeover on + an insertion of characters

To add the character in the end of a file without creation of a new file echo "]">> file
And how similarly to add in the file beginning?

11

Re: Line end changeover on + an insertion of characters

Panfilov wrote:

sed-r ':a; N; $! ba; s/\n +/,/g'

O-o-o... Your kung fu is stronger than mine.

12

Re: Line end changeover on + an insertion of characters

Well like gathered all
sed-r ':a; N; $! ba; s/\n +/,/g ' FILE; sed-i-e ' 1 s / ^ / [/; ' FILE; echo "]">> FILE

13

Re: Line end changeover on + an insertion of characters

The problem was showed, sed of 15 gigabyte does not work on a file, i.e. the command fulfills without errors, but changes nothing
The same command on a slice of the big file fulfills, that to do?

14

Re: Line end changeover on + an insertion of characters

Sintetik wrote:

the problem was showed, sed of 15 gigabyte does not work on a file, i.e. the command fulfills without errors, but changes nothing
The same command on a slice of the big file fulfills, that to do?

At the people fulfills and on 25 Gb files.
Try lajf-hak OPTIMIZING FOR SPEED with preliminary find .