How can I replace a line which contains only -------- by |||

Posted by mimou on Stack Overflow See other posts from Stack Overflow or by mimou
Published on 2011-01-17T09:37:43Z Indexed on 2011/01/17 9:53 UTC
Read the original article Hit count: 244

Filed under:
|
|

I have something like:

------------------------------------------------------------------------
r2 | username | 2011-01-16 16:52:23 +0100 (Sun, 16 Jan 2011) | 1 line
Changed paths:
   D /foo
Removed foo
------------------------------------------------------------------------
r1 | username | 2011-01-16 16:51:03 +0100 (Sun, 16 Jan 2011) | 1 line
Changed paths:
   A /foo
created foo
------------------------------------------------------------------------

My target is to identify the file added by the "username" in a specific date. Thus, I need to have the combination (username, 16 Jan 2011, A) to insure that it is the right file ands then print foo. My idea is to:

  1. delete the white spaces
  2. change the newlines into |
  3. get rid of the --------------- and replace them with newlines

but the problem is that I couldn't replace the ------- since they are mixed with other characters.

------------------------------------------------------------------------
|r2|username|2011-01-1616:52:23+0100(Sun,16Jan2011)|1line|Changedpaths:|D/foo|Removedfoo|
------------------------------------------------------------------------
|r1|username|2011-01-1616:51:03+0100(Sun,16Jan2011)|1line|Changedpaths:|A/foo|createdfoo|
------------------------------------------------------------------------

So I thought it would be a good idea to start by replacing the --------------- by a special character like ||| and then change this character by a newline using awk FS=||| OFS=\n Can anyone help me! thanks

© Stack Overflow or respective owner

Related posts about regex

Related posts about sed