Dec 1

Below is the code to remake the rm command. I remade it so I could send everything i delete to a trashbin. It sends it to your home/.Trashbin. If the directory isnt there, it makes it for you. After that it tests to see if there are any arguments after the command, and if there are 0 it sends back a message. If there are arguments it continues. If the second argument is the -r flag then it send everything after the flag to the trashbin, no matter what. If there isnt the -r present then it only sends files to the trashbin, and if it finds out you tried to delete a directory, it sends back an error. This was made in a bourne-again shell.

Thanks!

Checkout the code below. Read the rest of this entry »

Nov 19

Hey all, this is a guessing game I have written for my operating systems class. It was written for a bash (bourne again shell) unix operating system.

It uses a simple while loop with if loops nested in it to see if the guessed number is higher or lower than the random number.

#!/bin/sh
#gueessing game
biggest=50
guess=0
guesses=0
number=$(( $$ % $biggest ))
while [ $guess -ne $number ] ; do
echo -n "Guess? " ; read guess
if [ "$guess" -lt $number ] ; then
echo "... bigger!"
elif [ "$guess" -gt $number ] ; then
echo "... smaller!"
fi
guesses=$(( $guesses + 1 ))
done
echo "Right!! Guessed $number in $guesses guesses."
exit 0