I have this block in a text file. In vi (switching on the visualization of the end-of-line characters with :set list
as per View line-endings in a text file) it reads
SHARE_INFO_FOR: SHARE/u_MYGROUP/$
USER/GROUP SHARES PRIORITY STARTED RESERVED CPU_TIME RUN_TIME ADJUST$
u_zc 10000 3333.333 0 0 0.0 0 0.000$
$
SHARE_INFO_FOR: SHARE/u_MYSECONDGROUP/$
If I try to isolate this with sed I would use a multiple lines regexp
sed -rn '/SHARE\/u_MYGROUP\//{:a;N;/^$/{/.*/p;d};ba}'
sed does not identifies the ending line of the block. whereas if I explicitly put the content of if next non-empty line it works.
sed -rn '/SHARE\/u_MYGROUP\//{:a;N;/SHARE\/u_MYSECONDGROUP\//{/.*/p;d};ba}'
My problem is of course that in general I do not know what is the group name in the next line so I wanted to delimit the interesting block using the name as a beginning marker and the empty line as end of block marker.
Do you see why ^$
is not working as a delimiter for the regexp in sed?