-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovie-tracker
executable file
·63 lines (50 loc) · 1.05 KB
/
movie-tracker
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
#!/bin/sh
dir="$HOME/data/movie-tracker"
if [ ! -d "$dir" ]
then
mkdir -p "$dir"
if [ $? -ne 0 ]
then
echo "Creation of $dir failed. Quitting."
exit
fi
fi
printf "What movie did you see? "
read title
printf "When did you see it? "
read date
printf "Who is the director? "
read director
printf "When was the film originally released? "
read release
printf "What is the director's country? "
read country
echo "Where did you see the movie?"
test ! -f "$dir/movies.csv" ||
list=$(sed -n 's/".*"//;2,$p' "$dir/movies.csv" | cut -s -d, -f6 | sort -u)
IFS='
'
set -- $list
i=1
for cinema; do
printf "\t%2d) $cinema\n" $i
i=$(($i+1))
done
printf "\t$i) Other\n"
read option
# To add a range limit.
while ! expr "$option" : '^[1-9][0-9]*$' > /dev/null
do
printf "Choose a valid number (1-$i): "
read option
done
if [ $option -lt $i ]
then
cinema=$(eval "echo $(echo "$"$option)")
else
printf "Where? "
read cinema
fi
printf "Rating? "
read rating
echo "$date,$title,$director,$release,$country,$cinema,$rating" >> $HOME/data/movie-tracker/movies.csv