简体   繁体   English

与bash的空间

[英]Spaces with bash

I'm trying to make an export of a folder with spaces... but I did'nt find out how... 我正在尝试导出一个带空格的文件夹...但我没有发现如何...

:~> export PATH="/home/solo/VirtualBox\ VMs/"
:~> cd $PATH
bash: cd: /home/solo/VirtualBox\: No existe el fichero o el directorio

I thought that with a "\\" I could solve but did not. 我认为用“\\”我可以解决,但没有。

You've already escaped it with the quotes; 你已经用引号逃脱了它; there's no need for a backslash, just don't forget the quotes each time. 不需要反斜杠,每次都不要忘记引号。 But FFS, don't use $PATH ; 但是FFS, 不要使用$PATH ; that env var is important . env var很重要

In bash , when you write inside " or ' , you don't need to escape many of the characters. bash ,当你在"'里面写字时,你不需要逃避许多角色。

In your case, 在你的情况下,

export PATH="/home/solo/VirtualBox VMs/"

should do. 应该做。

Note that, space, and many other characters have special meaning and you escape them so bash won't get confused and use them with their special meanings. 请注意,空格和许多其他字符具有特殊含义,您可以逃避它们,因此bash不会混淆并使用它们的特殊含义。 When you put stuff inside " , there is no confusion because everything is taken literally (almost) and there is no need for escaping. 当你把里面的东西" ,没有混乱,因为一切都是从字面上看(几乎),没有必要逃跑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM