эквивалент stdout в чистом двоичном коде?

Вы можете использовать sedдля объединения следующей строки с текущей, если текущая строка не содержит 4 |символов:

<file sed -e :1 -e 's/|/|/4;t' -e 'N;s/\n/ /;b1'

В некоторых реализациях sedесть -iили -i ''для редактирования файлов в -место(-i.backдля сохранения оригинала с расширением .back), так что с ними вы можете сделать:

sed -i -e :1 -e 's/|/|/4;t' -e 'N;s/\n/ /;b1'./*.csv

Для редактирования всех не -скрытых csvфайлов в текущем каталоге.

То же с комментариями:

<file sed '
   :1
     s/|/|/4; # replace the 4th | with itself. Only useful when combined with
              # the next "t" command which branches off if the previous
              # substitution was successful
     t
     # we only reach this point if "t" above did not branch off, that is
     # if the pattern space does not contain 4 "|"s
     N; # append the next line to the pattern space
     s/\n/ /; # replace the newline with a space

   # and then loop again in case the pattern space still does not contain
   # 4 "|"s:
   b1'
0
19.09.2020, 04:14
0 ответов

Теги

Похожие вопросы