to find the number of users logged in

Hi,

can u say to display the number of users that logged before me.

thanks

who | awk '{print $1}'|uniq

Hope this helps

 who | awk ' { print $1 }' | sort -ud

Thanks.
Nagarajan G

but it shows
+ who
+ awk '{ print $1 }'
+ sort -ud
these lines also.

who | awk '{usr[$1]}END{for(i in usr)print i}'

You have the -x option on (prints executed commands and their arguments).
To disable this option :

set +x

An example :

$ set -x
$ date
+ date
Wed May 30 09:40:54 DFT 2007
$ set +x
$ date
Wed May 30 09:41:01 DFT 2007
$

Jean-Pierre

can u say to display the number of users that logged before me.

Hi,

can anybody say --- the no. of users logged before me.

"i want no. of users logged in before me"

Your are continuously bumping up your posts. This is against the rules. Please refrain from breaking the rules.

(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post or send a private message where your goal is to get an answer more quickly.

On my AIX box, the result of who is sorted on the loogin date/time.

$ who
Name         Line          Time              Hostname
usr001      pts/0       May 24 15:03    (1.2.1.39)  
usr099      pts/1       May 30 07:54    (1.2.1.11)  
usr000      pts/3       May 30 08:58    (1.3.1.2)   
usr099      pts/4       May 30 14:35    (1.2.1.11)  
$

The current terminal is given by the tty command

$ tty
/dev/pts/4
$

In the output from who, all the users logged in before me are listed before the line with current user and current terminal.

$ tty=$(tty | sed 's_^/dev/__')
$ echo $tty
pts/4
$ echo $USER
usr099
$ who | awk -v user=$USER -v tty=$tty '$1==user && $2==tty {exit} 1'
usr001      pts/0       May 24 15:03    (1.2.1.39)  
usr099      pts/1       May 30 07:54    (1.2.1.11)  
usr000      pts/3       May 30 08:58    (1.3.1.2)   
$

The final script :

tty=$(tty | sed 's_^/dev/__')
who | \
awk -v user=$USER -v tty=$tty '$1==user && $2==tty {exit} {print $1}' | \
sort -ud

Jean-Pierre.