Go Back   PCMech Forums > Linux Support > Linux OS and Software Assistance

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-31-2003, 07:26 PM   #1
Member (6 bit)
 
SteveAH10's Avatar
 
Join Date: Dec 2001
Location: Northern Illinois
Posts: 60
Question Linux Script File

I am attempting to learn scripting and I have started a script in vi to calculate numbers. I want it to add, subtract, divide, and multiply integers.

I want to enter " calck plus 1 2 3 4", where plus is the operation (sub, divide, and Mult will be used as well), and the numbers are to be acted upon.
I have written a test script which follows

:

total=0

for plus in $1

do
if [ $1 = plus ]
then
total=`expr$total+$*`
echo $total
fi
done

But I know my expression is not right! Can anyone give me an idea of what I am doing wrong. I would appreciate any help I can receive.
( I was thinking I might be able to use Case instead of if as well)

Steve
SteveAH10 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:12 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2