-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregular_exp
More file actions
executable file
·58 lines (33 loc) · 936 Bytes
/
regular_exp
File metadata and controls
executable file
·58 lines (33 loc) · 936 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#-------------------------------------------
name="Tejas"
echo "This is ${name}'s home"
string="I am a programmer"
echo "${string//programmer/developer}"
#---------------------------------------------
read -p "validate length: " len
pat="^[0-9]{5}$"
if [[ $len =~ $pat ]]; then
echo "length is five"
else
echo "length is not valid"
fi
#--------------------------------------------
read -p "Enter two numbers: " num1 num2
sum=$((num1+num2))
echo "$num1 + $num2 = $sum"
read -sp "Enter password: " word
if [[ "$word" == "password" ]]; then
echo "password is correct"
else
echo "Incorrect password"
fi
#--------------------------------------------
OIFS="$IFS"
IFS=","
read -p "enter two values seperated by comma: " num1 num2
num1=${num1//[[:blank:]]/0}
num2=${num2//[[:blank:]]/}
sum=$((num1+num2))
echo "addition of num1 + num2 = $sum"
IFS="$OIFS"#--------------------------------------------