#!/bin/bash pids=($(ps aux | grep '[0-9] .*node.* /home/user/client' | while read user pid rest; do echo $pid; done)) if [[ "${pids}" != "" ]]; then echo "Killing ${pids[@]}." kill ${pids[@]} else echo "Running client not found." fi