08-15-2002
You didn't say which shell -
CSH:
#!/bin/csh -f
set counter = 0
set var = "file"
loop:
@ counter = $counter + 1
echo $var$counter
if ($counter > 5) then
exit
endif
goto loop
KSH:
#!/bin/ksh
counter=0
var="file"
while [ $counter -lt 5 ]
do
counter=$(($counter+1))
echo $var$counter
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am trying to process error files in selected directories. I can count the files that are there and export the contents to a file for either emailing or printing. The next step is to move the files to a processed directory with the name changed to .fixed as the last extension.
for file in... (2 Replies)
Discussion started by: jagannatha
2 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a variable v_iteration which can equal any 3 digit number eg 001 or 926
I would like to dynamically make a new variable name up using this 3 digit number
eg
v_another_variable_001=fred
v_another_variable_926=joe
The following are examples of what I have tried
... (2 Replies)
Discussion started by: Bab00shka
2 Replies
3. Shell Programming and Scripting
Is there a way to do make-style computed variable names in awk? e.g. in make
foo = bar
bar = wocket
I can get "wocket" with $($(foo))
Alternatively can you list all defined variables in awk?
thanks (4 Replies)
Discussion started by: craig06y
4 Replies
4. UNIX for Dummies Questions & Answers
Hi Everyone,
I was just curious if you are allowed to begin a variable name with a number. For example, I would really like to have the variable 8DAY_AVERAGE. But my shell script only seems to allow EIGHTDAY_AVERAGE. Is there a way I can get the former to work? I am using bash. Thanks a lot!
... (1 Reply)
Discussion started by: msb65
1 Replies
5. Shell Programming and Scripting
I am trying to write a piece of code that will call a value from an array. There are multiple arrays that I need to call data from. Only one array needs to be used based on the step within the program. The arrays have the names "cue_0", "cue_1", and so on.
I can't figure out how to call a value... (2 Replies)
Discussion started by: vockleya
2 Replies
6. Shell Programming and Scripting
Hi All ,
I am having confusion in a shell script. Please guide me.
I need to get multiple files (number of files vary time to time, file names are separated by '|') using FTP get from the remote server.
Actually, i call the FTP function in a loop. At the last step, i need to move all the get... (3 Replies)
Discussion started by: spkandy
3 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I am using BASH. I have encountered a situation where the following is necessary (but I am not sure how to do it):
#Define multiple arrays, whose names only differ by a number:
ARRAY_1=(1 2 3)
ARRAY_2=(4 5 6)
ARRAY_3=(7 8 9)
#Define ARRAY_AMOUNT, the number of arrays. In this case... (1 Reply)
Discussion started by: msb65
1 Replies
8. Shell Programming and Scripting
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
Discussion started by: Vryali
2 Replies
9. Shell Programming and Scripting
If I run two different TCSH scripts simultaneously that use identical variable names will this cause any problems? (1 Reply)
Discussion started by: thibodc
1 Replies
10. Shell Programming and Scripting
Hi All
I think I might have bitten off more than I can chew here and I'm hoping some of you guys with advanced pattern matching skills can help me.
What I want to do is index the occurrence of variable names within a library of scripts that I have. Don't ask why, I'm just sad like that...
... (3 Replies)
Discussion started by: bbq
3 Replies
LEARN ABOUT DEBIAN
mousex::nativetraits::counter
MouseX::NativeTraits::Counter(3pm) User Contributed Perl Documentation MouseX::NativeTraits::Counter(3pm)
NAME
MouseX::NativeTraits::Counter - Helper trait for counter attributes
SYNOPSIS
package MyHomePage;
use Mouse;
has 'counter' => (
traits => ['Counter'],
is => 'ro',
isa => 'Num',
default => 0,
handles => {
inc_counter => 'inc',
dec_counter => 'dec',
reset_counter => 'reset',
},
);
my $page = MyHomePage->new();
$page->inc_counter; # same as $page->counter( $page->counter + 1 );
$page->dec_counter; # same as $page->counter( $page->counter - 1 );
DESCRIPTION
This module provides a simple counter attribute, which can be incremented and decremented.
If your attribute definition does not include any of is, isa, default or handles but does use the "Counter" trait, then this module applies
defaults as in the "SYNOPSIS" above. This allows for a very basic counter definition:
has 'foo' => (traits => ['Counter']);
$obj->inc_foo;
PROVIDED METHODS
These methods are implemented in MouseX::NativeTraits::MethodProvider::Counter. It is important to note that all those methods do in place
modification of the value stored in the attribute.
set($value)
Set the counter to the specified value.
inc Increments the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount.
dec Decrements the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount.
reset
Resets the value stored in this slot to it's default value.
METHODS
meta
method_provider_class
helper_type
SEE ALSO
MouseX::NativeTraits
perl v5.14.2 2011-12-04 MouseX::NativeTraits::Counter(3pm)