When I copy any file and paste it in console or text editos it is passed as
file:///home/user/path/file
when I pass it to script it is not found
What is the easiest way to convert that to normal linux path or somehow make script support it?
for example
cat file:///home/user/path/file
says
No such file or directory
Best Answer
To remove the
file://
prefix from the URL, you can use sed:What the above does:
file://
in any line that begins withfile://
with nothing. This effectively removesfile://
from the URL leaving only/home/user/path/file
To use this from a script you can try the following:
Now the error message is:
(Please note that it refers to the correct filename instead of the URL.)
It would be much cleaner to store the converted filename in a shell variable and use it afterwards.