1

So this question was asked some times already, but the answers didn't seem to work for me. So I have this simple script

#!/bin/bash
charon_id = $(pidof charon)
kill -1 $charon_id

And console says charon_id: command not found*

I've tried different versions, with " around the $( ), ; after the lines, even the $(... 2>&1) I saw somewhere. Nothing has helped so far. Suggestions?

* translated from console language into English

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
GreenThor
  • 113
  • 3

1 Answers1

5

Your problem is with spaces

You wrote

charon_id = $(pidof charon)

This means "run the command charon_id with two parameters; first is the = character and the second is the output of the $(..) command

It should be

charon_id=$(pidof charon)

Now you assign the output to the variable.

Stephen Harris
  • 42,369
  • 5
  • 94
  • 123
  • Now I feel like the noob I am in shell scripting D: Thanks alot! ;) – GreenThor Jul 15 '16 at 13:06
  • 1
    @GreenThor don't worry about feeling like a noob; you should have seen the mistakes I made when I was one. Fortunately that was almost 30 years ago; I've learned since then :-) – Stephen Harris Jul 15 '16 at 13:09