You could use awk to split the URL into /-delimited fields, then print out the ones you want to keep e.g. if
Code:
url='www.website.com/2014/4/30/this-is-my-page'
then
Code:
$ awk -F/ '{print "Redirect",$0,$1"/"$NF}' <<< "$url"
Redirect www.website.com/2014/4/30/this-is-my-page www.website.com/this-is-my-page
or something like this with sed, which just deletes anything matching (more-or-less) /yyyy/mm/dd?
Code:
$ echo "Redirect $url" $(sed -r 's|/[0-9]+/[0-9]+/[0-9]+||' <<< "$url")
Redirect www.website.com/2014/4/30/this-is-my-page www.website.com/this-is-my-page
Bookmarks