我正在尝试为 Bash 中的变量分配绝对路径:
#!/bin/bash
DIR= "/home/foobar"
echo "$DIR/test"
输出:
./test.sh: line 2: /home/foobar: Is a directory
/test
我不明白那里发生了什么,请帮助我。
最佳答案
去掉"/home/foobar"
前的空格:
#!/bin/bash
DIR="/home/foobar"
echo "$DIR/test"
关于linux - Bash:为什么我不能为变量分配绝对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26540352/