Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Simple question, I think? (http://www.programmingforums.org/showthread.php?t=11887)

Phonetic Nov 15th, 2006 12:38 AM

Simple question, I think?
 
I'm relatively new to scripting so please take it easy on me. Right now I'm working on two different scripts, using the bash shell in linux. The first one keeps giving me a "command not found error. Here's the script.

sales=$1
costs=$2

echo $1
echo $2
net=[[ $sales-$costs ]]
echo "The networth is $net"

The second one is:

read -p "What is your name? " name
read -p "How old are you? " age

if [[ $name==tyler ]]
then
if [[ $age==19 ]]
then
clear
echo "calcuating"
sleep 1
clear
echo "calcuating."
sleep 1
clear
echo "calcuating.."
sleep 1
clear
echo "calcuating..."
sleep 1
clear
echo "calcuating...."
sleep 1
clear
echo "calcuating....."
sleep 1
clear
echo "You should see a doctor about that."
sleep 3
clear
echo "End!"
sleep 3
clear
else
clear
echo "calcuating"
sleep 1
clear
echo "calcuating."
sleep 1
clear
echo "calcuating.."
sleep 1
clear
echo "calcuating..."
sleep 1
clear
echo "calcuating...."
sleep 1
clear
echo "calcuating....."
sleep 1
clear
echo "I'd say you're relatively normal."
sleep 3
clear
echo "End!"
sleep 3
clear
fi
fi

I'm sorry for the long post, thanks in advance for any help.

andro Nov 15th, 2006 1:11 AM

:

#!/bin/bash
sales=$1
costs=$2

echo $1
echo $2
net=$(($sales-$costs))
echo "The networth is $net"


Phonetic Nov 15th, 2006 2:45 AM

thank you very much!

I just don't understand, why did I need that $ in front of the parenthesis?

Arevos Nov 15th, 2006 4:31 AM

Quote:

Originally Posted by Phonetic (Post 118961)
I just don't understand, why did I need that $ in front of the parenthesis?

That's just how it was built. It's a shorthand syntax for evaluating an expression: $((<expression>))


All times are GMT -5. The time now is 1:34 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC