Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
accept the selling price (range 5¢ to $1.05) as a command line argument (cents only); reject prices out of range or not multiples of 5; return to the operating system with a usage message
2. Relevant commands, code, scripts, algorithms:
if statment
%
3. The attempts at a solution (include all code and scripts):
if [ $1 -ge 5 -a $1 -le 105 -a $(( $1 % 5 == 0 )) ]
then
echo The selling price has been set to $1
else
Invalid amount
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Ryerson University, Toronto, Canada, Ikhari, CCPS 393
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
$(( )) isn't part of the [ ] syntax, it gets substituted, so what you're doing amounts to "-a 0" or "-a 1" which doesn't make sense. I'd put it outside the [ ].
You certainly made a good start on it though! Only minor fixes needed:
Before doing that if statement at all you should check if $1 is blank if [ -z "$1" ] ; then echo "no first parameter" ; exit ; fi otherwise that $(( )) will be a syntax error when $1 is blank.
one more question. I want to skip the first echo statement the first time the loop gets entered
while [ $total_inserted -lt $selling_price ] #keep prompting for more funds until selling price achieved
do
echo "You have inserted a total of ${total_inserted} cents. Please insert $total_remaining more cents"
echo 'Please insert coins (NDQR)'
read coin_inserted
Otherwise the progam will tell user that he entered 0 cents, which is pointless. Any ideas???
I am working on a script to get the final total size and so far have the following and wondering if this can be improved.
# Compare the desired size of each lvm to the standard size. If it is desired is larger than calculate the difference and keep that value as the amount to add to that LVM. ... (5 Replies)
Hi folks,
I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex.
I have a bunch of update statements with all columns in a file which I need to convert into insert statements.
UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
The intended result should be :
PDF converters
'empty line'
gpdftext and pdftotext?xml version="1.0"?>
xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters
gpdftext and pdftotext</note-content>... (9 Replies)
Greetings, I need some assistance here as I cannot get a sed line to work properly for me. I have the following list:
Camp.S01E04.720p.HDTV.X264-DIMENSION
Royal.Pains.S05E07.720p.HDTV.x264-IMMERSE
Whose.Line.is.it.Anyway.US.S09E05.720p.HDTV.x264-BAJSKORV
What I would like to accomplish is to... (3 Replies)
Hi All,
I am using Unix ksh script.
I need to insert values to a table using the o/p from a slelect statement.
Can anybody Help!
My script looks like tihs.
---`sqlplus -s username/password@SID << EOF
set heading off
set feedback off
set pages 0
insert into ${TB_NAME}_D... (2 Replies)
In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands.
How do I write the "do nothing" statement in the following example?
Example:
if (( "$x"="1" && "$y"="a" && "$z"="happy" ))
then
do nothing
else
command
command
fi... (3 Replies)
Hi,
Can anyone help me with the syntax for finding out remainder of two integers.
Ex: 10/3 ... it should return 1.
Is fmod function will be helpful here? I am not able to find out usage of it.
Kindly help.
Regards,
Malay Maru (3 Replies)