Background
I am running an SSH server and have this user that I want to delete. I cannot delete this user because he is currently running a few processes that I need to kill first.
This is the pipeline I am using currently using to find out all the process ids of the user I am currently using:
ps -u user | awk '{print $1;}'
The output looks like this:
PID
2121
2122
2124
2125
2369
2370
I want to pipe this to kill -9
to kill all processes so I can delete this stupid user like this:
ps -u user | awk '{print $1;}' | sudo xargs kill -9
But this does not work because of the PID
header:
kill: failed to parse argument: 'PID'
The question
I am thinking that there has to be a simple Unix command to remove the first line of input.
I am aware that I can use tail
for this but I don't want to count how many lines the input contains to figure out exactly how many I want to display.
I am looking for something like head
or tail
but inverted (instead of displaying only the first/last part of the stream it displays everything but the start/end of stream).
Note
I managed to solve this issue I had by simply adding | grep [[:digit:]]
after my awk
command but I am still looking for a way to delete first line of a file as I think would be quite useful in other scenarios.
NR
e.g.awk 'NR>1 {print $1;}'
. Better yet - usepgrep -u
orpkill -u
– steeldriver Dec 31 '15 at 14:30awk
command) works. – wefwefa3 Dec 31 '15 at 14:33