-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessinggame.sh
More file actions
41 lines (32 loc) · 1.04 KB
/
guessinggame.sh
File metadata and controls
41 lines (32 loc) · 1.04 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
#!/bin/bash – Execute the file using the Bash shell.
# #!/bin/sh – Execute the file using the Bourne shell, or a compatible shell,
# with path /bin/sh
# #!/bin/csh -f – Execute the file using csh, the C shell, or a compatible
# shell, and suppress the execution of the user’s .cshrc file on startup
# #!/usr/bin/env python – Execute using Python by looking up the path
# to the Python interpreter automatically via env
# #!/usr/bin/perl -T – Execute using Perl with the option for taint checks
# First program of the UNIX Workbench Project (UWP)
function guess {
if [[ num_files -lt $1 ]]
then
echo "Sorry, too low. Try again:"
read user_in
elif [[ num_files -gt $1 ]]
then
echo "Sorry, too high. Try again:"
read user_in
elif [[ num_files -eq $1 ]]
echo "Good guess!"
flag_loop=1
fi
}
flag_loop=0
num_files=$(eval ls | wc -l)
echo "Hello, how many files are in this folder?"
read user_in
while [[ flag_loop -eq 0 ]]
do
guess user_in
done
echo "See you another time."