Eu tenho as linhas semelhantes às abaixo.
[1] 07:37:38 [bb..], qw, Exited with errojjjvice not known
[2] 07:37:39 [bfb.], fg, , This is FILE1, Stderrle or directory
[3] 07:37:39 [SU..], b b, ,, Stderr: bash: /sauch file or directory
cat: /root/file1: No, such, file or directory
[4] 07:37:39 [SUCCESS], gh, , This is F :, No, such file or directory
[5] 07:37:39 [SUCCESS], jk, ,, Stderr: bash: , No, such file or directory
nnnnnn, oot/file1: No, such, file or directory
hylll;; ooppgggh
[6] 07:37:39 [SUCCESS], jjj, ,, Stderr: bash: No, such file or directory
cat: /root/file1: No, such, file or directory
É necessário anexar a linha à linha de saída original do cmd seguida de vírgula. E deve começar com colchetes contendo números como abaixo
[1] 07:37:38 [bb..], qw, Exited with errojjjvice not known
[2] 07:37:39 [bfb.], fg, , This is FILE1, Stderrle or directory
[3] 07:37:39 [SU..], b b, ,, Stderr: bash: /sauch file or directory, cat: /root/file1: No, such, file or directory
[4] 07:37:39 [SUCCESS], gh, , This is F :, No, such file or directory
[5] 07:37:39 [SUCCESS], jk, ,, Stderr: bash: , No, such file or directory, nnnnnn, oot/file1: No, such, file or directory, hylll;; ooppgggh
[6] 07:37:39 [SUCCESS], jjj, ,, Stderr: bash: No, such file or directory, cat: /root/file1: No, such, file or directory
Responder1
Se bem entender, você deseja juntar linhas que não começam com colchetes.
Aqui está uma maneira perl:
perl -0777 -i -ape 's/\R(?=[^[])/, /g' file
Explicação:
\R # any kind of linebreak (i.e. \r, \n, \r\n)
(?= # positive lookahead, zero-length assertion that make sure we have after:
[^[] # any character that is not an opening square bracket
) # end lookahead
Substituição:
, # a comma followed by a space
Resultado para determinado exemplo:
[1] 07:37:38 [bb..], qw, Exited with errojjjvice not known
[2] 07:37:39 [bfb.], fg, , This is FILE1, Stderrle or directory
[3] 07:37:39 [SU..], b b, ,, Stderr: bash: /sauch file or directory, cat: /root/file1: No, such, file or directory
[4] 07:37:39 [SUCCESS], gh, , This is F :, No, such file or directory
[5] 07:37:39 [SUCCESS], jk, ,, Stderr: bash: , No, such file or directory, nnnnnn, oot/file1: No, such, file or directory, hylll;; ooppgggh
[6] 07:37:39 [SUCCESS], jjj, ,, Stderr: bash: No, such file or directory, cat: /root/file1: No, such, file or directory