问题
I am trying to just run a simple bash command but i'm not sure what i'm misssing
#!/bin/bash
$person = Craig Baiey
echo $person
echo '$person'
echo "$person"
everytime I run it i get an error line 2: =: command not found
$person
回答1:
Space is the problem around =. It should be:
person="Craig Baiey"
- You don't assign into variable with
$in name. - And quotes are also required there.
btw this line won't print the variable's value:
echo '$person'
As shell won't expand it due to presence of single quotes. It will instead literal $person
回答2:
Remove the $ before person on line 2:
#!/bin/bash
person="Craig Baiey"
echo $person
来源:https://stackoverflow.com/questions/22722709/fedora-bash-program-not-working-properly