Here's info sed
:
The '/' characters may be uniformly replaced by any other single
character within any given 's' command. The '/' character (or whatever
other character is used in its stead) can appear in the REGEXP or
REPLACEMENT only if it is preceded by a '\' character.
So the %
is just an arbitrary delimiter. The canonical delimiter is /
, but that collides with your pattern which is also /
.
In other words, %/
isn't an escaped /
. They're independent characters.
The expression breaks down like this:
s Replace
% Delimiter
/[^/]*$ Search pattern
% Delimiter
Empty replacement string
% Delimiter
Which is completely analogous to a simple s/foo/bar/
:
s Replace
/ Delimiter
foo Search pattern
/ Delimiter
bar Replacement string
/ Delimiter