How do i store the output of a bash command in a variable? [duplicate]
问题 This question already has answers here : How do I set a variable to the output of a command in Bash? (14 answers) Closed 5 years ago . I'm trying to write a simple script for killing a process. I've already read Find and kill a process in one line using bash and regex so please don't redirect me to that. This is my code: LINE=$(ps aux | grep '$1') PROCESS=$LINE | awk '{print $2}' echo $PROCESS kill -9 $PROCESS I want to be able to run something like sh kill_proc.sh node and have it run kill