找不到Bash变量分配和命令 [英] Bash variable assignment and command not found
本文介绍了找不到Bash变量分配和命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Shell脚本,可以让我访问脚本中的全局变量,但是当我尝试创建自己的脚本时,它会响应:找不到命令.
I have a shell script that will let me access global variables inside the script, but when I try to create my own, it responds with: command not found.
#!/bin/bash
J = 4
FACE_NAME = "eig$J.face"
USER_DB_NAME = "base$J.user"
运行上面的脚本时,我得到:
When I run the above script I get:
./test1.sh line 2: J: command not found
./test1.sh line 3: FACE_NAME: command not found
./test1.sh line 4: USER_DB_NAME: command not found
有什么想法吗?我在Windows XP下使用Cygwin.
Any ideas?? I'm using Cygwin under Windows XP.
推荐答案
尝试一下(注意,我已经从=
的任一侧移除了空格):
Try this (notice I have removed the spaces from either side of the =
):
#!/bin/bash
J="4"
FACE_NAME="eig$J.face"
USER_DB_NAME="base$J.user"
在声明变量时,Bash不喜欢空格-最好将每个值都用引号引起来(但这并不那么重要).
Bash doesn't like spaces when you declare variables - also it is best to make every value quoted (but this isn't as essential).
这篇关于找不到Bash变量分配和命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文