-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.sh
More file actions
executable file
·46 lines (46 loc) · 821 Bytes
/
employee.sh
File metadata and controls
executable file
·46 lines (46 loc) · 821 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
#!/bin/bash
#touch employee.txt
#find /home/ubuntu/shellprogram1/employee.txt -empty -name employee.txt
#if [ "$?" -eq 0 ]
#then
echo " name age phonenumber department" >> employee.txt
#fi
echo "type to do operation "
read x
if [ $x == "new" ]
then
echo "enter name is"
read name
a=$name
echo " enter age is "
read age
b=$age
echo " enter ph num"
read ph
c=$ph
echo " enter dept"
read dept
d=$dept
echo "$a $b $c $d" >> employee.txt
fi
if [ $x == "list" ]
then
cat employee.txt | sort
fi
if [ $x == "remove" ]
then
echo " enter name of record to delete"
read name
sed -i /$name/d employee.txt
fi
if [ $x == "clear" ]
then
#sed employee.txt
truncate -s 0 employee.txt
fi
if [ $x == "lookup" ]
then
echo " please enter name to lookup"
read name
grep $name employee.txt
fi