I am making a basic bash script. I am trying to get a PID value and store it in a variable. I got my script setup like this:
getPID = pgrep -f app.jar
kill -9 $getPID
And then, I realized that I was only printing pgrep -f app.jar
onto the terminal. So I tried:
getPID = $(pgrep -f app.jar)
kill -9 $getPid
And still no luck, is there a way to get pgrep
value and store it in the variable?
I came across multiple questions. And still no luck. I also tried this, not too sure what does $$
does.
pgrep -f app.jar
getPid = $$
kill $getPid
I am using Ubuntu 16.04 terminal.