Question: The who command lists all users that are currently logged in to the computer, as well as (among other things) when the user logged in.
The who command lists all users that are currently logged in to the computer, as well as (among other things) when the user logged in.
Provide a command line, using pipes, that provides, as its only output, the name of the user that has been logged in for the longest in the computer, according to the output of who (called without arguments). Here are a few other commands that may be useful:
- The
sortcommand includes options to sort based on a different field of the output, rather than from the start. Note thatwhoprovides the login time with year first, which simplifies string-based comparison in sort. - Commands like
awkandsedcan be used to parse and retrieve only part of the provided information (e.g., only one column of a specific line). Alternatively, a combination of commands likecutandheadcan be used to provide this functionality.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
