I want to print the pid when finding matched process while the match pattern is inputted:
ps aux | awk -v in="$1" '/in/{print $1}'
It seems the former awk sentence is not right. After checking many results in google like this, I change my script in the following but still cannot work:
ps aux | awk -v in="$1" '/$0 ~ in/{print $1}'
or
ps aux | awk -v in="$1" '($0 ~ in) {print $1}'
pgrep "$1"would be better option...