-
Notifications
You must be signed in to change notification settings - Fork 0
/
select-filesystems
executable file
·61 lines (34 loc) · 1.45 KB
/
select-filesystems
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
#!/bin/bash
# please note that df -h | tail -n +2 | awk {'print $1'} can also do the same thing very easily.
#creating a file called current-df-output.txt
df -h | tail -n +2 | awk {'print $1'} >> current-df-output.txt
################ creating a file and using it for counting values
#echo seeing total lines/drives ; setting a counter ; 2 loops to compare and put the O/P of current file into an array
LINES=`wc -l current-df-output.txt | awk '{print $1}'`
##echo the number of lines are $LINES
#echo setting up a counter for seeing the total number of drives in the current file
COUNTER=0
while [ $COUNTER -lt $LINES ]
do
#echo "We're in the while loop"
for j in `cat current-df-output.txt`
do
#echo the value of thevar is $j
NAMES[$COUNTER]=$j
#echo The name is $NAMES
((COUNTER=COUNTER+1))
done
done
#echo Finally asking for disk to select
echo "Please select a Disk by choosing a number from the options below."
echo "Please note that if you erronously choose a number not present in the list, the program will exit for security purposes as a failsafe so that a new, uninitialiazed disk does not get corrupted."
select DIR in "${NAMES[@]}"
do
[ -z $DIR ] || echo Selected $DIR && break
done
i
############### done
################ using another approach now
#deleting the current file
rm current-df-output.txt && #echo The current file was cleared
exit 0