On my system, I have about 75 users. Some uers have two or three sessions on the same systems. when I do w, it shows all the sessions. Is there any way to find only the users and not worry about how many sessions. For example: you can see sshe has four connection. I only want to know the users. From the results below, I am looking for
sak, apr, sshe, xzha, peter. I tried doing w |grep -v but not working.
That's not a reliable approach. If all of a user's sessions have been idle for a while, they will not be listed because !/days/ would exclude them all. The same condition will also exclude any sessions currently running a command line which includes "days". Any username in which the string "days" appears is also similarly doomed.
Similar issues apply to the use of !/PCPU/ .
In my opinion, a much more robust solution would specifically exclude the header: