In my bash script I need to extract just the path from the given URL. For example, from the variable containing string:
http://login:password@example.com/one/more/dir/file.exe?a=sth&b=sth
I want to extract to some other variable only the:
/one/more/dir/file.exe
part. Of course login, password, filename and parameters are optional.
Since I am new to sed and awk I ask you for help. Please, advice me how to do it. Thank you!
Using only bash builtins:
What this does is:
*://*/
(so this would be your protocol and hostname+port)/
note: the quotation marks aren't actually needed here, but I find it easier to read with them in