-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete_record.sh
executable file
·76 lines (61 loc) · 1.31 KB
/
delete_record.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/bash
#this script needs to be called with arguments 2 the DB name and table name
while true
do
key=$(yad \
--center \
--text-align=center \
--title "7amasa DB" \
--form --field="Enter record Primary key: " \
--button=gtk-ok:0 \
--button=gtk-cancel:1 \
)
choice0=$?
if [ $choice0 = 1 ]
then
break
elif [ $choice0 = 252 ]
then
kill -9 `ps --pid $$ -oppid=`; exit
elif [ $choice0 = 0 ]
then
key=$(echo $key | awk 'BEGIN {FS="|" } { print $1 }')
line=`grep -w "$key" /var/7amasaDB/$1/$2`
linenumber=`grep -wrne "$key" /var/7amasaDB/$1/$2 | cut -d: -f 1`
if [ -z "$line" ]
then
yad \
--title "7amasa DB Engine" \
--center \
--text-align=center \
--text "This id not exist!"\
--button="back":1
else
tmpForm=$(yad \
--center \
--title "7amasa DB Engine" \
--text "Are you sure that you want to delete this record ?" \
--button="yes":1 \
--button="NO":2 \
)
choice=$?
case $choice in
1)
ln="$linenumber"d
sed -i "$ln" /var/7amasaDB/$1/$2
tmpForm=$(yad \
--center \
--title "7amasa DB Engine" \
--text "$DBName Deleted Successfully" \
--button=gtk-go-back:1 \
)
./table_index.sh
;;
2) ./table_index.sh
;;
252) kill -9 `ps --pid $$ -oppid=`; exit
;;
esac
fi
fi
done