How to use file protocol to access a directory on local system?
44,114
Solution 1
If you have a requirement to be able to access generic URLs from your shell, try using curl as a replacement for your cat:
curl file:///path/to/file.txt
curl http://www.domain.com/file.txt
But as other posters have pointed out, the shell itself doesn't understand URLs.
Solution 2
If you have to deal with file:///usr/local on the command line, you could just remove the "file://" part. And do then a normal your command, e.g.:
echo "file:///usr/local/" | sed 's/file:\/\///' | cd
Author by
omg
Updated on April 29, 2020Comments
-
omg about 4 years
like
/usr/local
?I tried
file:///usr/local
but failed[root@www2 robot]# cd file:///usr/local -bash: cd: file:///usr/local: No such file or directory
-
Venedictos about 15 yearsIf your talking about FireFox, then yes, I know, I slipped, shame on me. It's fixed now though.
-
supercheetah about 15 yearsNot necessarily wget, but rather curl (i.e. "cat url").
-
Pete over 9 years"the file: protocol only exists in web browers"? Not so. The URL for a file is not something that is limited to web browsers. For example, as an argument to the collection() XPath function to get a group of XML docs from the local disk.