在.env中设置带空格的变量(Setting variables with spaces within .env)
我有一个带有一堆变量的
.env
文件,我只是遇到了一个错误。其中一个变量有空格。
TEST="hello world"
所以当我运行这个时, 在这里回答了这个问题。
env $(<.env)
我收到这个错误。
env: world"': No such file or directory
如何在.env中设置带空格的变量?
I have a
.env
file with a bunch of variables and I just came across an error.One of the variables has spaces.
TEST="hello world"
So when I run this, learned about in this answer here.
env $(<.env)
I get this error.
env: world"': No such file or directory
How do I set variables with spaces within .env?
原文:https://stackoverflow.com/questions/29422799
最满意答案
我猜你是从Eclipse中运行它的。 Eclipse环境不提供控制台。 我建议你从终端手动运行程序或使用其他东西,比如
BufferedReader
。I'm guessing you run it from within Eclipse. The Eclipse environment does not provide a console. I suggest you run your program manually from the terminal or use something else such as a
BufferedReader
.
相关问答
更多-
逃避保留字符 \\[Detail\\] escape reserved characters \\[Detail\\]
-
在Java中,您还需要\\t以避免\ 。 以下代码作品: String test="asd asd asd xsdv"; String[]t=test.split("\\t"); for(String st : t){ System.out.println(st); } 输出是: asd asd asd xsdv in java you need \\t to also escape the \. following code works: String test="asd asd ...
-
正则表达式的控制台或扫描仪?(Console or Scanner for Regex?)[2023-12-05]
我猜你是从Eclipse中运行它的。 Eclipse环境不提供控制台。 我建议你从终端手动运行程序或使用其他东西,比如BufferedReader 。 I'm guessing you run it from within Eclipse. The Eclipse environment does not provide a console. I suggest you run your program manually from the terminal or use something else suc ... -
首先,使用一台扫描仪而不是每次都重新创建扫描仪。 此外,你的for循环循环一次额外的时间。 Scanner sn = new Scanner(System.in); System.out.println("Give me a size "); int n = sn.nextInt(); ArrayList
list = new ArrayList (); for (int i = 0; i < n; i++){ System.out.println("Give me ... -
这是因为Scanner可能匹配一个空String ,而StringTokonizer则不会。 在这种情况下,部分“部分!但是” Scanner匹配后面的空格! 符号,而StringTokenizer则没有。 It is because Scanner may match an empty String, while StringTokonizer will not. In this case in the part "section! But" Scanner matches the whitespace ...
-
如何使用Scanner根据正则表达式为多个变量赋值(How to use Scanner to assign value to multiple variables based on regex)[2021-03-23]
首先,Java 无法做到这一点,因为java不使用指针。 您可能希望的最好的方法是返回值列表/数组。 其次,“不”; JDK中没有任何类似的东西能做到这一点。 但是,您可以在与变量相同的代码行中相当简单地执行此操作: String input = "CR127-0772"; // given this got from console String st = input.replaceAll("\\d.*", ""); // delete from 1st digit onwards String a = ... -
正则表达式找到令牌 - Java Scanner或其他替代品(Regex to find tokens - Java Scanner or another alternative)[2022-05-30]
这个想法是从特定情况开始到一般情况。 试试这个表达式: Java string: "([\"'])(?:[^\"']+|(?!\\1)[\"'])*\\1|\\|\\||<=|&&|[()\\[\\]{};=#]|[\\w.-]+" Raw pattern: (["'])(?:[^"']+|(?!\1)["'])*\1|\|\||<=|&&|[()\[\]{};=#]|[\w.-]+ 这里的目标不是用一个hypotetic分隔符拆分,而是逐个实体匹配。 请注意,替代顺序定义了优先级(你不能把= befo ... -
如何让re.Scanner尝试下一个选项? 简短的回答:你做不到。 既然我们不能有负面的前瞻 我有点不解。 因为你能: (r"a(?!a)", retry_under_some_conditions) 那会工作,扫描仪会尝试下一个规则。 所以我假设你做不到的原因,与你的项目/实际问题有关。 我有一些嵌套组。 当我们返回None时,我们跳过这个文本。 这只是因为扫描仪的工作原理。 在创建扫描仪时,它会采用您的模式,在本例中为a和aa 。 这些将组合成(a)|(aa) 。 子模式是重要的部分,因为它与扫描仪的 ...
-
你的useDelimiter()和next()组合有问题。 useDelimiter("")将在next()上返回1长度子字符串,因为空字符串实际上位于每两个字符之间。 也就是说,因为"\r\n".equals("\r" + "" + "\n")所以"\r\n"实际上是两个记号, "\r"和"\n"通过"" 。 要获得Matcher行为,你需要找到无视定界符的findWithinHorizon 。 Pattern newLinePattern = Pattern.compile("(\\r\\n?| ...
-
传递给useDelimiter的参数是一个正则表达式。 所以在这种情况下,您可以使用与"[,.]"匹配的表达式,或者. 。 The argument passed to useDelimiter is a regular expression. So in this case, you can just use an expression like "[,.]" which matches either , or ..