如何使用文件协议访问本地系统上的目录?
就像/usr/local
?
我尝试了 file:///usr/local
但失败了
[root@www2 robot]# cd file:///usr/local
-bash: cd: file:///usr/local: No such file or directory
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您需要能够从 shell 访问通用 URL,请尝试使用curl 来替代您的 cat:
但正如其他发帖者指出的那样,shell 本身并不理解 URL。
If you have a requirement to be able to access generic URLs from your shell, try using curl as a replacement for your cat:
But as other posters have pointed out, the shell itself doesn't understand URLs.
如果您必须在命令行上处理 file:///usr/local,您可以删除“file://”部分。 然后执行正常的命令,例如:
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.:
据我所知,bash 和 cd 不能跨多个协议运行。 如果您想通过其他协议访问内容,则必须将它们安装到本地文件系统。
您不会尝试 cd 到用户在某些 Web 表单上提供的某个位置,是吗?
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?
file:///
不适用于bash
或衍生 shell。它可以在大多数浏览器中工作,并且可能在
wget
和curl
中工作,但bash
不是网络浏览器。file:///
doesn't work onbash
or derivative shells.It will work in most browsers, and possible
wget
andcurl
, butbash
is not a web browser.file:
协议仅存在于网络浏览器中。 在 Firefox 中尝试一下,应该可以工作。 要在 shell 中执行此操作,只需使用Don't use
file:
。 这与你不能这样做的原因是一样的(但你必须使用诸如
wget
或curl
之类的东西)。The
file:
protocol only exists in web browsers. Try it in Firefox, it should work. To do it in a shell, just useDon't use
file:
. It's the same reason why you can'tWhich would be awesome (but you have to use something like
wget
orcurl
).