-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShellScriptQues.txt
More file actions
40 lines (30 loc) · 809 Bytes
/
ShellScriptQues.txt
File metadata and controls
40 lines (30 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#Define function
read -p "Enter a Password: " password
countAND(){
for var in $password;do
if [[ $var = '&' ]];then
return 10
else
return 20
fi
done
}
passwordMatch(){
countAND $password
#echo $?
if [[ ${#password} -ge 8 ]];then
if [[ $password == *[0-9]* ]];then
if [[ $password == *[@#$%*+-=]* || $? = 20 ]];then
echo "Password Successfully Matched"
else
echo "Must contain at least one of the following non-alphabetic characters: @, #, $, %, &, *, +, -, ="
fi
else
echo "Must contain at least one numeric character"
fi
else
echo "Minimum length of 8 characters"
fi
}
passwordMatch $password