I understand that final result of
sed -e :a -e '$d;N;2,5ba' -e 'P;D' file
I don't understand what :a, ba
mean. Also I get confused why -e
is specified 3 times?
I understand that final result of
sed -e :a -e '$d;N;2,5ba' -e 'P;D' file
I don't understand what :a, ba
mean. Also I get confused why -e
is specified 3 times?
-e
specifies a sed script of which there are 3.
:a
is a label for use with b and t commands.
$d;N;2,5ba
means match the last line and delete. The next input line is appended into pattern space. For lines 2, 5 we'll branch to label :a
.
Last script prints pattern space up to the first newline, and deletes up to the first newline in the pattern space.