I need to print UID PID PPID PRI NI VSZ RSS STAT TTY TIME columns using ps of processes with typed name.
GNU nano 2.0.6
File: file2
ps o uid,pid,ppid,ni,vsz,rss,stat,tty,time | grep $2 > $1
cat $1
echo "enter pid of process to kill:"
read pid
kill -9 $pid
But it prints nothing, when I use this command with argument $2 = bash (this process exists)
UPDATE
GNU nano 2.0.6
File: file2
ps o uid,pid,ppid,ni,vsz,rss,stat,tty,time,command | grep $2 | awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9}' > $1
cat $1
echo "enter pid of process to kill:"
read pid
kill -9 $pid
This works for me, but actually this solution IMHO isn't the best one. I use shadow column command, after what grep name and print all columns excluding command.