0

I am trying to make a script in the shell that executes a page's specific HTML.

However, whenever I try to set the variable to curl https://scratch.mit.edu, it shows =: command not found, I searched this on Google and it tells me to set the variable like this:

PROJECT = curl https://scratch.mit.edu

However, this does not meet my needs because it shows

PROJECT: command not found

So, I try this:

$PROJECT = curl https://scratch.mit.edu

It did work for clearing the variable error but then, this happens

=: command not found

EDIT: I just realized -

it should be

$PROJECT=curl https://scratch.mit.edu

but then this is what the error is:

Command '=curl' not found, did you mean:
   command 'curl' from snap curl (7.84.0)
   command 'curl' from deb curl (7.81.0-1ubuntu1.4)
See 'snap info <snapname>' for addition versions

What do I do?

Note that this question is different from this as I cannot use the function curl and assign the value to the variable

  • 1
    `PROJECT=$(curl https://scratch.mit.edu)` – Charles Duffy Oct 13 '22 at 03:50
  • Wait -- if you're not trying to assign to a variable, what _are_ you trying to do? You say directly "when I try to set the variable"; why shouldn't we believe you're trying to set a variable? – Charles Duffy Oct 13 '22 at 03:51
  • If you're trying to store _the command itself_ in the variable, read [BashFAQ #50](https://mywiki.wooledge.org/BashFAQ/050) – Charles Duffy Oct 13 '22 at 03:54
  • I tried this - PROJECT=$(curl https://scratch.mit.edu) But now when I run echo $PROJECT, this is what it shows - curl – IAMATP On Scratch Oct 13 '22 at 04:00
  • It is unclear, **what** you want to achieve in the end. Do you want to store the **output of a command** in a variable, or do you want to store the textual form of the command itself in a variable? In the latter case, `PROJECT` should be an array, not a scalar. – user1934428 Oct 13 '22 at 07:38
  • `PROJECT=$(curl scratch.mit.edu)` stores the output of `curl`. To have the string `curl` itself stored implies that you left off the `$`; it's what you would get from `PROJECT=(curl scratch.mit.edu); echo $PROJECT`. – Charles Duffy Oct 13 '22 at 12:45

0 Answers0