linux - Unix command to create file:/// URI based on the file's directory (pwd) -
linux - Unix command to create file:/// URI based on the file's directory (pwd) -
i write filepath uri in unix command-line emulator.
desired output:
file:///c|/directory/filename.ext
using sed , pwd can close not quite there because
$ pwd /c/directory/
...gives me lower-case drive , no pipe.
is there improve way?
you can sed
; has y
command case-conversion, though convoluted because have go through hold space pattern space. easier utilize perl - has 1 or more modules (such uri , uri::file), though simple version produced regular expressions.
#!/usr/bin/env perl utilize strict; utilize warnings; foreach $name (@argv) { if ($name =~ m%^/([a-za-z])(/.+)%) { printf "file:///%c|%s\n", uc($1), $2; } else { print stderr "$0: unexpected name format - no /x/ drive letter prefix ($name)\n"; } }
(untested code.)
linux git unix command-line cygwin
Comments
Post a Comment