I'm writing a bash script that disconnects idle sessions but writes to the tty a few seconds before terminating it to make sure it really is not being used.
The format for
write user [tty].
I'm starting with a tty string, i.e "pts/1".
I know I can find the user next to the tty name in "who" and "w", but am uncertain of how to put the username (i.e john) in a variable. Would this require a regex? I was originally looking for a single command but
w don't have such options in their documentation.