I don't write pure bash and I don't think we have seen your code to populate the array. Might be worth posting that script.
Remember that array elements are numbered from zero. In your case zero to six (i.e. seven elements).
Here's a bit of test code to get you started on how to walk the array and how to refer to the elements in shell script. You will need to change variable names to match the rest of your script and maybe change "echo" to "printf" depending on what you have been taught.
The idea is to build your script in simple stages and test each stage.
Once you can read back you array of the seven numbers the user typed you are in a position to insert code to do more (like find the highest value). Finding the median will be interesting.
I am trying to change this :
Albert Einstein 52
Peter Scott 22
Hilary Smith 48
Joan Bakewell 30
Catherine Maguire 26
into
Albert Einstein Pass
Peter Scott Fail
Hilary Smith Pass
Joan Bakewell Fail
Catherine Maguire Fail
I have to use a if statement that says:
if field 3 is... (2 Replies)
I had different problem scenarios with IF statement. Can any expert please enlighten me on the difference with these scenarios. Thank you.
1st Scenario:
testdate=`date +%Y%m`
test=`cat /var/log/database0.$testdate*.log | grep "Errors found during processing" | tail -10`
if
then
... (4 Replies)
This is for a program I have to do to calculate the day of the week.
I need to write an if statement that will do the following:
if day is 29 and year is odd, don't calculate dayif ( day == 29 && year == ??? )I know how to do it for the day but I don't know how to do it for the year. (4 Replies)
I am kind of new in Unix and i have to make a menu. I want to put an if statement in the menu. you should enter the filename and it goes to that file. How do i do this? (1 Reply)
Good morning all!
I want to know if Im interpreting this if statement below right.
if(((1) || (0)) && (1)){
do stuff;
}
This is saying: if true piped into false, then true, then do stuff. Right?
What does the && stand for?
thanks in advance!
ben (3 Replies)
I am writing a script that does a search for a argument in a file and lists all like occurrences. The script verifies that it is a file and then runs another script that list the lines. My problem is that I need the script to accept a file or a directory and then go to that directory check all... (1 Reply)
Hi
I am very new to Unix programming and shell scripting. I am trying t figure out how to write a little script that will output the number of directories. I can find the number of directories using ls -l | grep "^d" | wc -l I can not figure out how to do it so when I type the name... (8 Replies)
Hi guys,
Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers:
1) Use a while loop to determine the largest number in the range.
... (2 Replies)
I came across a bash script that outputs the forecast for the day and the max temperature but at the end of the day the max temperature disappears ($6) and I am left with "°C" after the forecast.
Here is the script:
#! /bin/bash
curl -s --connect-timeout 30... (7 Replies)
Discussion started by: _light_
7 Replies
LEARN ABOUT MINIX
local
local(n) [incr Tcl] local(n)
__________________________________________________________________________________________________________________________________________________NAME
local - create an object local to a procedure
SYNOPSIS
itcl::local className objName ?arg arg ...?
_________________________________________________________________DESCRIPTION
The local command creates an [incr Tcl] object that is local to the current call frame. When the call frame goes away, the object is auto-
matically deleted. This command is useful for creating objects that are local to a procedure.
As a side effect, this command creates a variable named "itcl-local-xxx", where xxx is the name of the object that is created. This vari-
able detects when the call frame is destroyed and automatically deletes the associated object.
EXAMPLE
In the following example, a simple "counter" object is used within the procedure "test". The counter is created as a local object, so it
is automatically deleted each time the procedure exits. The puts statements included in the constructor/destructor show the object coming
and going as the procedure is called.
itcl::class counter {
private variable count 0
constructor {} {
puts "created: $this"
}
destructor {
puts "deleted: $this"
}
method bump {{by 1}} {
incr count $by
}
method get {} {
return $count
}
}
proc test {val} {
local counter x
for {set i 0} {$i < $val} {incr i} {
x bump
}
return [x get]
}
set result [test 5]
puts "test: $result"
set result [test 10]
puts "test: $result"
puts "objects: [itcl::find objects *]"
KEYWORDS
class, object, procedure
itcl local(n)