Thursday, October 27, 2022

[SOLVED] How to extract a column value from a command output in shell script

Issue

I am trying to write a shell script where I want to kill a list of processes given by fuser command.

enter image description here

The output of fuser is given. I want to kill the pids listed

kill -9 157909 1504107 1504111 1504112 2690311 3206490

How do I do that?


Solution

   -k, --kill
         Kill processes accessing the file.  Unless changed with -SIGNAL,
         SIGKILL is sent.  An fuser process never kills itself,  but  may
         kill  other  fuser  processes.   The  effective  user  ID of the
         process executing fuser is  set  to  its  real  user  ID  before
         attempting to kill.

fuser -k will do it.



Answered By - Diego Torres Milano
Answer Checked By - Marie Seifert (WPSolving Admin)