An actual game using Terminal on the Mac is something with guessing numbers
Open the Terminal.App from your Mac by holding down command space and typing Terminal
RANDOM=$$
while true
doecho "can you guess a number between 1 and 10 : "
read
echo The number is :
echo `expr $RANDOM % 9 + 1`
echodone
can you guess a number between 1 and 10 :
3
The number is :
5can you guess a number between 1 and 10 :
4
The number is :
5can you guess a number between 1 and 10 :
9
The number is :
4can you guess a number between 1 and 10 :
The number is :
3Control-C to tell the computer to stop, remember the computer is not very smart like humans
See all posts about Fun infinite loops
Fun infinite loops : bash #2
A second fun loop with Terminal on the Mac is something with time
Open the Terminal.App from your Mac by holding down command space and typing Terminal
while true
do
date
date +%T
sleep 1
done
Thu Nov 7 07:38:50 PST 2013
07:38:50
Thu Nov 7 07:38:51 PST 2013
07:38:51
Thu Nov 7 07:38:52 PST 2013
07:38:52
Thu Nov 7 07:38:53 PST 2013
07:38:53Control-C to tell the computer to stop, remember the computer is not very smart like humans
See all posts about Fun infinite loops
Fun infinite loops: bash #1
C. somehow got interested again in programming and she opened the
Terminal
App from her Mac and typed
echo why doesn't this work
quote>
quote>
quote>
quote>
I told her the single quote character is a special character that the not so smart computer need the human to escape it
Control-C would tell the computer to abort whatever it is doing
echo "why doesn't this work
Then she asked how do we do that infinite loop
hey you c8
while true
do
echo hey you c8
sleep 1
done
hey you c8
hey you c8
hey you c8
hey you c8
hey you c8
hey you c8
hey you c8
hey you c8Fun!