shell練習1

寫一個腳本:要求以下:
1:依次向/etc/passwd目錄中的每個用戶問好,並指出其UID號!(eg:Hello root,your uid is 0)
2:統計這個腳本共有多少個帳戶?bash


#!/bin/bashide


name=`cat /etc/passwd |awk -F: '{print $1}'`ui


for u in $name
spa

doorm

    i=`id $u |awk -F'=' '{print $2}' |awk -F'(' '{print $1}'`it

    uid_num=`grep $u:x /etc/passwd |awk -F: '{print $3}'`class


    if [ $i == $uid_num ]awk

    thengrep

        echo "Hello $u, your uid is $i !"im

    else

        echo "Wrong!!!"

    fi


done


y=`cat /etc/passwd |wc -l`

echo "There are $y users.

相關文章
相關標籤/搜索