Shorten URL's in KeePass-DB

75 Views Asked by At

I do have a KeePass-Database which has up to 100 entries with url's in it. It has a bunch of entries where the url looks like this:

Now I want to "shorten/cleanup" this URL's to this:

I could export the Database to csv and re-import it, but this forces me to create a new db which i try to avoid. Is there maybe another way? If not, can somebody write a line of code which runs preferrably in windows (if not, linux is also possible) to fix this in the csv?

Something like:

  • Search for the third occurence of / and delete everything afterwards OR
  • Search for * //*/ and delete everything afterwards

could work, or am I wrong?

Thank you!

1

There are 1 best solutions below

0
Kent On BEST ANSWER

where the url looks like this:

https://banking.consorsfinanz.de/onlinebanking-cfg/loginFormAction.do

Now I want to "shorten/cleanup" this URL's to this:

https://banking.consorsfinanz.de/

Awk

awk 'BEGIN{FS=OFS="/"}{print $1,$2,$3,""}'

example:

$ awk 'BEGIN{FS=OFS="/"}{print $1,$2,$3,""}' <<< "https://domain.name/foo/bar/blah/whatever"
https://domain.name/

Sed

sed 's#\(https://[^/]*/\).*#\1#' 

example:

$ sed 's#\(https://[^/]*/\).*#\1#' <<<"https://domain.name/foo/bar/blah/whatever"
https://domain.name/