How can I convert a file path to an URI in the command-line?
Example:
/home/MHC/directory with spaces and ümläuts
to
file:///home/MHC/directory%20with%20spaces%20and%20%C3%BCml%C3%A4uts
|
|
One way to do this is using
will convert the path to an URI. The "file://" part of the URI will be left out, but you can easily add that via a bash one-liner:
or directly
or
Many thanks to Michael Kjörling for the references! |
|||||
|
|
You can also use the Perl module URI::file directly from the command line:
|
|||
|
|