1. the user is required to enter the name, age, and gender.
#! /Bin/bash
Read-p "Please input your name:" name
Read-p "Please input your age:" age
Read-p "Please input your sex:" sex
Echo "Your name is $ name, age is $ age, sex is $ sex ."
2. Write a script arvg. sh to read the input parameter variables, such as sh arvg. sh test12. Then, ask the user if they want to create a directory,
If the user answers yes or YES, it creates a directory for the user and then asks whether to create a file for the user. If yes is returned
Create test01 in the Created directory.
#! /Bin/bash
If [$ #-lt 1]; then
Echo "Please like 'sh test. sh a B C '"
Fi
Read-p "are you mkdir file? Please enter yes/YES or no: "qq
If [$ qq = yes] | [$ qq = YES]; then
Mkdir $1
For I in $ (seq 1 10 );
Do
Touch $1/test $ I
Done
Else echo "No file created"
Exit 0
Fi
3. Change the password randomly:
#! /Bin/bash
#2011/07/10 by larry
LOG = PassChange 'date + % F'. log
> $ Pass
Cat/etc/passwd | while read line
Do
Id = 'echo $ line | awk-F ":" '{print $3 }''
User = 'echo $ line | awk-F ":" '{print $1 }''
PASS = $ RANDOM
If [$ id-lt 500]; then
Echo "$ user is system users ."
Elif [$ id-gt 500]; then
Echo $ RANDOM | passwd $ user -- stdin
Echo "$ USER $ id $ RANDOM" >>$ LOG
Fi
Done
#####################################
#! /Bin/bash
#2011/07/10
Now = 'date + % F'
File =/etc/passwd
For user1 in 'cat $ file | awk-F: '$3 <500 {print $1 }''
Do
Echo $ user1 is systerm user
Done
For user2 in 'cat $ file | awk-F: '$3> 500 {print $1 }''
Do
Echo $ RANDOM | passwd $ user2 -- stdin>/dev/null
Echo "$ user2 $ RANDOM"> Pass $ now. log
Done
This article is from the "Larry's learning path" blog