Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

filename stripping, a-la the patch(1) --strip=NUM option

0 views
Skip to first unread message

Ivan Shmakov

unread,
Sep 30, 2009, 10:30:17 AM9/30/09
to
I wonder, is there an existing module to do filename (path)
stripping, like it is implemented in, e. g., patch(1)?

STRIP (0, "/a/b/c/d") => "/a/b/c/d" ;
STRIP (1, "/a/b/c/d") => "a/b/c/d" ;
STRIP (2, "/a/b/c/d") => "b/c/d" ;
STRIP (3, "/a/b/c/d") => "c/d" ;
STRIP (4, "/a/b/c/d") => "d" ;
STRIP (5, "/a/b/c/d") => "d" ;

And if there's no such module, would there be any specific
advices on how to write such a code and on how to wrap it into a
module?

PS. Even better if it would do it the other way around, too, like:

STRIP (-1, "/a/b/c/d") => "d" ;
STRIP (-2, "/a/b/c/d") => "c/d" ;
STRIP (-3, "/a/b/c/d") => "b/c/d" ;
STRIP (-4, "/a/b/c/d") => "a/b/c/d" ;
STRIP (-5, "/a/b/c/d") => "/a/b/c/d" ;
STRIP (-6, "/a/b/c/d") => "/a/b/c/d" ;

--
FSF associate member #7257

0 new messages