echo
echo 'You guessed it!'
echo 'It took you $TRIES tries.'
echo
This script could be saved as
# chmod a+rx
Here's a test run of the script:
$ guess-it
Number-guessing Game
--------------------
I have a secret number between 1 and 100.
Enter guess #1:
Too low!
Enter guess #2:
Too low!
Enter guess #3:
Too low!
Enter guess #4:
Too high!
Enter guess #5:
Too high!
Enter guess #6:
Too low!
Enter guess #7:
You guessed it!
It took you 7 tries.
Another test, using an alternate upper limit:
$ guess-it 50
Number-guessing Game
--------------------
I have a secret number between 1 and 50.
Enter guess #1:
Too low!
Enter guess #2:
Too low!
Enter guess #3:
Too high!
Enter guess #4:
You guessed it!
It took you 4 tries.
4.12.1.7. Login and initialization scripts
When a user logs in, the system-wide script
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge ( ) {
if ! echo $PATH | /bin/egrep -q '(^|:)$1($|:)' ; then
if [ '$2' = 'after' ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# ksh workaround
if [ -z '$EUID' -a -x /usr/bin/id ]; then
EUID=Qid -uQ
UID=Qid -ruQ
fi
# Path manipulation
if [ '$EUID' = '0' ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1