I need a little help to finish off a little code. I want to do a query with the who command, but I only want to see the users listed I give in arguments with username and pts/num, ordered by the time of login. It works for 1 user, but I would like to get it work with more users. Here it is atm:
#!/bin/bash
who |
awk '($1 ~ /'$*'/){print $3 $4" "$1" "$2}' |
sort -n |
awk '{ print $2, $3 }'
How can I make it work with multiple users?
Sample use:
./script username1 username2 blabla pete stevie
...awk '($1 ~ /'${*// /\|/}'){...doesn't work. At least in bash 3.2. My intent is to globally sub spaces with '|' chars, so the arg-list would be converted to an awkORable expression, like/username1|username2|blabla|.../. Can any bash-ites say if this is possible? Hm... doesn't work in RH ksh either. Good luck to all.