How can we extract a column from output in which whitespace is not in a regular format?
For example, when we type
ps -ef, it shows all the process, process id's.... etc. How can we get only the last column or any specific column?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
-o option you can specify what fields should be displayed. List of available fields you can find in
man ps or using
For example using
ps -eo user,command will display usernames and commands - something like this:
root /bin/login -- root /sbin/getty
You can also use
-O and parameters which will cause using some default fields and appending that specified by you, but if you want to parse output I will recommend