Subject: RE backtrack for last slash fails when backslashblank involved

From: Peter Benjamin <[email-masked]>
Date: Sat, 15 Dec 2018 14:07:08 -0800

Backtrack last slash RE does not work when there are "\ " involved.

RE:
sed -e 's/^\(.*\)\/\([^\/]*\)$/\2\t\1\/\2/' findm

$ cat findm
/media/userid/data/movies/movie\ 1\ a.m4v
/media/userid/data/movies/movie\ 1\ a.extra.m4v
/media/userid/data/movies/movie\ 2.m4v
/media/userid/data/movies/movie\ 3.m4v
/media/userid/data/movies/movie4.m4v
/media/userid/data2/movies/data.m4v

STDOUT

$ sed -e 's/^\(.*\)\/\([^\/]*\)$/\2\t\1\/\2/' findm
/media/userid/data/movies/movie\ 1\ a.m4v
/media/userid/data/movies/movie\ 1\ a.extra.m4v
/media/userid/data/movies/movie\ 2.m4v
/media/userid/data/movies/movie\ 3.m4v
movie4.m4v	/media/userid/data/movies/movie4.m4v
data.m4v	/media/userid/data2/movies/data.m4v

----------------------------------------

Ubuntu 16.04

$ sed --version
sed (GNU sed) 4.2.2

$ uname -a
Linux *** 4.4.0-140-generic #166-Ubuntu SMP Wed Nov 14 20:09:47 UTC
2018 x86_64 x86_64 x86_64 GNU/Linux

------------------------

Same backtrack last slash RE in perl works:

perl -n -e 'chomp;s/^(.*)\/([^\/]*)$/\2\t\1\/\2/;print"$_\n"' findm

STDOUT
movie\ 1\ a.m4v	/media/userid/data/movies/movie\ 1\ a.m4v
movie\ 1\ a.extra.m4v	/media/userid/data/movies/movie\ 1\
a.extra.m4v
movie\ 2.m4v	/media/userid/data/movies/movie\ 2.m4v
movie\ 3.m4v	/media/userid/data/movies/movie\ 3.m4v
movie4.m4v	/media/userid/data/movies/movie4.m4v
data.m4v	/media/userid/data2/movies/data.m4v

The End