user3438676
user3438676

Reputation: 25

Fedora bash program not working properly

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

Upvotes: 0

Views: 111

Answers (2)

n34_panda
n34_panda

Reputation: 2677

Remove the $ before person on line 2:

#!/bin/bash
person="Craig Baiey"
echo $person

Upvotes: 0

anubhava
anubhava

Reputation: 785246

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

Upvotes: 4

Related Questions