forked from mo7amedsalah/DBEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescribe_table.sh
executable file
·50 lines (44 loc) · 1.54 KB
/
describe_table.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
#!/bin/bash
LC_ALL=C
shopt -s extglob
clear
source "functions"
source $(pwd)/use_Database.sh
while true; do
echo "Enter Table Name!!!!!!!!!!!"
IFS= read -r table_name
case $table_name in
#validate that the name must have not white spaces..
*\ *)
echo "-----------------------------------------------------------------------"
echo "Invalid Table name!! the name must be without no spaces..!! "
;;
#validate that the name must be letters only..
+([[:digit:]]))
echo "-----------------------------------------------------------------------"
echo "Invalid Table name!! the name must be letters and do not have whitespaces!!!!!"
;;
#the valid regix for name..
+([a-zA-Z]))
#IF table is Exist show the structure...
file_exist ${table_name}
if [ $? -eq 1 ]; then
echo "-----------------------------------------------------------------------"
echo "This is The Structure of $table_name"
echo "-----------------------------------------------------------------------"
awk 'NR == 2 { print }' $table_name
echo "-----------------------------------------------------------------------"
awk 'NR == 3 { print }' $table_name
echo "-----------------------------------------------------------------------"
break
else
#IF table is not exist
echo "-----------------------------------------------------------------------"
echo "The table is not exist"
fi
;;
*) echo "Invalid Table name!! name of Table must be lower or upper letters or mix and do not have whitespaces!!!! " ;;
esac
done
cd ..
source "DatabaseEngine.sh"