I want to retrieve the second column from ps
result:
test@pc:~$ ps -e | head -5 | cut -d '' -f1
PID TTY TIME CMD
1 ? 00:00:03 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
It does not work, I learned that it could be solve the a complicated way as:
test@pc:~$ ps -e | head -5 | gawk '{print $2}'
TTY
?
?
?
?
How could solve the problem with the generic tool of cut
?
ps
: you can control what columns it prints with the-o
(for output) switch like so:ps -e -o tname
. Heretname
is the column ID to print.