Hello, i am doing a project for school and i cannot figure out whats wrong with my 2 programs they dont seem to work at all.
the first program is called isprime and naturally it checks to see if hte number is prime or not
here is my code:
#!/usr/bin/bash
num=$1
echo you typed [$num]
if [ $num -gt 0 ] ; then
for mrv in `seq 2 $(($num/2))` ; do
modulo=$(( $num % $mrv))
if [ $modulo -eq 0 ] ; then
echo "is not prime"
exit
fi
done
else
echo ERROR
fi
my second program is called unscramble its supost to take in text and unscramble it to a word
#!/usr/bin/bash
word=$1
len=${#word}
cmd="egrep -i \"\<[$word]{$len}\>\" /usr/dict/words"
lp=0
while [ $lp -lt $len ] ; do
cmd="$cmd|grep ${word:$lp:1}"
ltr=${word:$lp:1}
dbl=`echo $word|egrep "($ltr).*\1"`
if [ -n "$dbl" ] ; then
echo $ltr is a double
fi
lp=$((lp+1))
done
eval "$cmd"
all this programming is very new to me and i can get confused easily any help would be great thank you