-1

I have a command that if I execute, it gives me below output:

[abctt]$ /abc/prr/test.sh config -get center.id
Connecting to the service endpoint at http://localhost:8003

POY Properties:
UU001

Now I want to extract "UU001" value and store in a variable and then print that variable value. So I tried something like below but it gives me error:

[abctt]$ id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id
id=UU001: Command not found.
id: Undefined variable.

What is wrong I am doing here?

flash
  • 1,455
  • 11
  • 61
  • 132
  • 3
    It looks like your first problem is that you're using `csh` not `bash` – jeremysprofile Jul 03 '18 at 20:12
  • Possible duplicate of [How to set a variable to the output of a command in Bash?](https://stackoverflow.com/questions/4651437/how-to-set-a-variable-to-the-output-of-a-command-in-bash) – jww Jul 04 '18 at 00:02

1 Answers1

1

Your code is correct inside of a script.

Try this:

export id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id

If you are using csh,

set id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Purple
  • 34
  • 4