Using arrays statistics, the number of users and type of shell

! # / bin / the bash
DECLARE -A shells (defined in associative array shells)
the while Read LL (reading / etc / passwd, ll variable)

do
type = `$ echo LL | awk -F: '{}. 7 Print $'` (type of a variable, the cut LL)
the let shells [$ type] ++
DONE </ etc / the passwd

for I in $ {! shells [@]}
do
 echo "$ I $ ::::: shells {[ I $]} "                                                        
DONE
~                                                                                       

[root@localhost ~]# bash tj2.sh
/sbin/nologin ::::: 17
/bin/sync ::::: 1
/bin/bash ::::: 3
/sbin/shutdown ::::: 1
/sbin/halt ::::: 1

Guess you like

Origin www.cnblogs.com/zjz20/p/11351573.html