-1

I have a package.json

{
   version: "1.0.0",
}

And below is my content

version=$(jq -r '.version' package.json)

echo version

of my bash.sh file, but I couldn't get the '1.0.0', I got version printed on my terminal, any clue why?

Vienna J
  • 71
  • 5

1 Answers1

0

Assuming this is bash, you are missing a dollar sign on this line:

echo $version

so you are printing a string instead of referring to a variable.

petrch
  • 1,807
  • 15
  • 19
  • 4
    Please don't answer typo questions; just leave a comment and vote to close. Properly speaking, you generally want to [quote shell variables](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) for scenarios where the OP's data contains shell metacharacters etc. – tripleee Jan 11 '23 at 12:05
  • ok, thanks for the comment. I will take to the heart. – petrch Jan 11 '23 at 14:26
  • but he helped me, can't we be kind to another human being? thanks @petrch!!!!!! – Vienna J Jan 12 '23 at 03:47
  • thank you both. It is always a balance between making the site work an individual and making it work for everyone. I understand that if we all stay organized, everyone will benefit from it. – petrch Jan 12 '23 at 16:15