How to use a file protocol to access a directory on a local system?

like /usr/local ?

I tried file:///usr/local but could not

 [ root@www2 robot]# cd file:///usr/local -bash: cd: file:///usr/local: No such file or directory 
+7
source share
5 answers

If you have a requirement to access shared 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 noted, the shell itself does not understand the URLs.

+6
source

If you need to deal with the file: /// usr / local on the command line, you can simply delete the "file: //" part. And execute the usual command, for example:

 echo "file:///usr/local/" | sed 's/file:\/\///' | cd 
+1
source

file:/// does not work on bash or derived shells.

This will work in most browsers, and possibly wget and curl , but bash not a web browser.

0
source

bash and cd do not work on several protocols, as far as I know. If you want to access materials through other protocols, you must connect them to the local file system.

You are not trying to connect to any location provided by the user in any web form?

0
source

Protocol file: exists only in web browsers. Try it in Firefox, it should work. To do this in a shell, simply use

  cd / usr / local /

Do not use file: This is for the same reason why you cannot

  cat http://www.google.com

Which would be awesome (but you should use something like wget or curl ).

-1
source

Source: https://habr.com/ru/post/1285706/


All Articles