I want to kill a process in specified port (variable)
export PORT=3030
netstat -ntlp | awk '$4~/:*${PORT}$/{gsub(/\/.*/,"",$NF);cmd="kill -9 "$NF;system(cmd)}'
but variable PORT doesn't get in the command.
|
I want to kill a process in specified port (variable)
but variable PORT doesn't get in the command. |
||||
|
|
|
Try using double quotes to wrap the You will need to either change the double quotes inside the command to single quotes or escape them with a backslash. |
|||
|
|
|
Adding to previous answers, just to show a way to fix your method:
or
|
|||
|
|
|
The single quote ask the shell to pass the enclosed string without any change. So Just use this: |
|||
|
|