-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectFromTable.sh
More file actions
executable file
·52 lines (50 loc) · 1.23 KB
/
selectFromTable.sh
File metadata and controls
executable file
·52 lines (50 loc) · 1.23 KB
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
#!/bin/bash
export LC_COLLATE=C #To sort ascii character
shopt -s extglob #import Advanced Regex
echo "Tables To Select From"
ls -F ./ | sed -n '/meta_/!p' | column -t
echo "Please Enter Table Name: "
read tableName
while [ true ]
do
if [ -f ./$tableName ]
then
select choice in "Select All Columns" "Select Specific Column" "Back To Table Menu" "Back to Main Menu" "Exit"
do
case $choice in
"Select All Columns" )
echo "$tableName Table Content is"
column -t -s "|" $tableName
. ../../tableMenu.sh
;;
"Select Specific Column" )
echo "`head -1 $tableName | column -t -s "|"`"
echo -n "Please Enter Column Name:"
read col_name
col_num=`awk -F"|" -v col="$col_name" 'NR==1{for (i=1;i<=NF; i++) if ($i==col) {print i;exit}}' $tableName`
awk -F"|" -v val="$col_num" '{print $val}' $tableName | column -t -s "|"
. ../../tableMenu.sh
;;
"Back To Table Menu" )
clear
. ../../tableMenu.sh
;;
"Back to Main Menu" )
cd ../..
clear
. ./mainmenu.sh
exit
;;
"Exit" )
exit
;;
* )
echo "Sorry, Please Select a correct number"
esac
done
else
echo "Table not found"
echo "Please Enter Table Name:"
read tableName
fi
done