Conditions based on the number of fields

If a user logs onto the server's physical console directly rather than logging on through a remote or graphical pseudo-terminal, then the lastlog output will not display the host field. To demonstrate this, I have logged onto my CentOS host directly to the tty1 console and avoided the GUI. The output from the previous awk control file shows that we now have the users tux and bob; bob though is lacking the host field as he is connected to a console.

Conditions based on the number of fields

Although in itself it's not an issue but it will be if we want to filter the fields and the two row's field numbers will vary where a field is omitted from some ...

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.