tags:

views:

304

answers:

5

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
+1  A: 

The file: protocol only exists in web browsers. Try it in Firefox, it should work. To do it in a shell, just use

cd /usr/local/

Don't use file:. It's the same reason why you can't

cat http://www.google.com

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

Zifre
"Firefox", dude. + however.
mateusza
So it only supports local?
Shore
If your talking about FireFox, then yes, I know, I slipped, shame on me. It's fixed now though.
Zifre
Not necessarily wget, but rather curl (i.e. "cat url").
supercheetah
A: 

file:/// doesn't work on bash or derivative shells.

It will work in most browsers, and possible wget and curl, but bash is not a web browser.

Christopher
A: 

bash and cd does not function across multiple protocols to my knowledge. If you want to access stuff through other protocols you have to mount them to the local filesystem.

You're not trying to cd to some location provided by a user on some web form are you?

whatsisname
+1  A: 

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.

MikeyB
+1  A: 

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
seb