Description
  • The first line of a block begins with `#' followed by a space and a tag, which implies the end of the preceding block.
Raw Input Desired Output
#100
ADD some/file/path
MODIFY diff/file/path
#104
MODIFY /another/modified/file/path
DEL /a/deleted/file/path
MODIFY /one/more/file/path
100 ADD some/file/path
100 MODIFY diff/file/path
104 MODIFY /another/modified/file/path
104 DEL /a/deleted/file/path
104 MODIFY /one/more/file/path
Script and Comments
Script1
[ 1] /^# /{
[ 2] h
[ 3] d
[ 4] }
[ 5] G
[ 6] s/^(.*)\n# (.*)/\2 \1/
Comments
  1. The `-r' option of GNU sed must be used or you have to escape every parenthesis used in Step [6].
  2. When the first line of a block is met, Steps [1] thru [4] are used to
  3. For the rest lines of a block: