Sponsored Content
Top Forums UNIX for Dummies Questions & Answers counter / increment problem within echo stmt Post 1091 by blaze on Wednesday 7th of February 2001 04:57:06 PM
Old 02-07-2001
Question

Simple script trying to increment a counter within an echo statement never gets past 1 - PLEASE HELP!

Thanks.
~~~~~~~~~~~

#!/bin/sh
stepup()
{
STEP=`expr $STEP + 1`
echo $STEP
}

#
# Initialize variables
#
STEP=0

echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
echo "Counter Value: `stepup`"
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Increment counter in ksh

Hello, I am making an increment counter in ksh. So i write a number in a temporary file and when I execute my script I read this file and I make +1. But how can I make this with a number with 6 digits , example 000009 + 1 = 000010 ... .... .... 000099 + 1 = 000100 Do anyone know... (5 Replies)
Discussion started by: steiner
5 Replies

2. Shell Programming and Scripting

counter problem

Hi, I'm attempting to take the following input list and create an output file as shown below. I've monkeyed around for long enough. Can anyone help? NOTE: fs*** will be header and I want to get a count on NY**. fs200a NY7A fs200b NY7B NY7B NY7B fs200c NY7C NY7C NY7C NY7C... (2 Replies)
Discussion started by: jwholey
2 Replies

3. Shell Programming and Scripting

Problem assigning a counter for particular pattern

Hi, I have a script that compares two files(which are updated dynamically by a daemon) and evaluate results from the comparision. For the first line of comparision from the file1, i will grep some part of the line in file with file1 and set a counter for that particular comparison. So for each... (12 Replies)
Discussion started by: reddybs
12 Replies

4. Shell Programming and Scripting

Problem outputting increment

With this script the output to the terminal does not increment. Can anyone tell me what I need to do to get this to increment output to the terminal? Here is the output mpath major,minor number ls: /dev/mapper/mpathp1: No such file or directory raw device output 253,44 echo raw device... (5 Replies)
Discussion started by: bash_in_my_head
5 Replies

5. Shell Programming and Scripting

Problem comparing String using IF stmt

Hi frnds Im facing an issues while trying to compare string using IF stmt, my code is: chkMsgName=`Service Fee Detail` if then if then if then echo "Valid File Ready for processing" fi fi ... (5 Replies)
Discussion started by: balesh
5 Replies

6. Shell Programming and Scripting

AWK counter problem

Hi I have a file like below ############################################ # ParentFolder Flag SubFolders Colateral 1 Source1/Checksum CVA 1 Source1/Checksum Flexing 1 VaR/Checksum Flexing 1 SVaR/Checksum FX 1 ... (5 Replies)
Discussion started by: manas_ranjan
5 Replies

7. Shell Programming and Scripting

increment counter as suffix starting with the rightmost digit

Hi, I would like to add a suffix to a file name but maintain the suffix length to 5 digits. For eg, output > 1st_file.00001, 2nd_file.00002...10th_file.00010....100th_file.00100 Can anyone please advise me on how to go about it? Platform: SunOS mps201a 5.9 Generic_118558-39 sun4u... (7 Replies)
Discussion started by: danish0909
7 Replies

8. Shell Programming and Scripting

problem with counter

i having a file xxxxxxxxxxxxxxx1234 ...........value can be change xxxxxxxxxxxxxxx1235 xxxxxxxxxxxxxxxx1236 . . . . xxxxxxxxxxxxxxxxx1300 ...........value can be change i want to cut last four characters of first line and last line and find the missing pattern. output should... (4 Replies)
Discussion started by: sagar_1986
4 Replies

9. Shell Programming and Scripting

Comparison of fields then increment a counter reading line by line in a file

Hi, i have a scenario were i should compare a few fields from each line then increment a variable based on that. Example file 989878|8999|Y|0|Y|N|V 989878|8999|Y|0|N|N|V 989878|8999|Y|2344|Y|N|V i have 3 conditions to check and increment a variable on every line condition 1 if ( $3... (4 Replies)
Discussion started by: selvankj
4 Replies

10. Shell Programming and Scripting

Bash counter increment not working

Hi all, I'm using Bash 4.3.8 on an Ubuntu system, and no matter what I try, incrementing a counter won't work. The simplest example would be something like this: #!/bin/bash myVar=0 myVar=$((myVar++)) echo myVar The variable should be 1, but it's always 0. I've tried every increment... (6 Replies)
Discussion started by: Zel2008
6 Replies
CALL_USER_FUNC(3)							 1							 CALL_USER_FUNC(3)

call_user_func - Call the callback given by the first parameter

SYNOPSIS
mixed call_user_func (callable $callback, [mixed $parameter], [mixed $...]) DESCRIPTION
Calls the $callback given by the first parameter and passes the remaining parameters as arguments. PARAMETERS
o $callback - The callable to be called. o $parameter - Zero or more parameters to be passed to the callback. Note Note that the parameters for call_user_func(3) are not passed by reference. Example #1 call_user_func(3) example and references <?php error_reporting(E_ALL); function increment(&$var) { $var++; } $a = 0; call_user_func('increment', $a); echo $a." "; // You can use this instead call_user_func_array('increment', array(&$a)); echo $a." "; ?> The above example will output: 0 1 RETURN VALUES
Returns the return value of the callback, or FALSE on error. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | The interpretation of object oriented keywords | | | like parent and self has changed. Previously, | | | calling them using the double colon syntax would | | | emit an E_STRICT warning because they were inter- | | | preted as static. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #2 call_user_func(3) example <?php function barber($type) { echo "You wanted a $type haircut, no problem "; } call_user_func('barber', "mushroom"); call_user_func('barber', "shave"); ?> The above example will output: You wanted a mushroom haircut, no problem You wanted a shave haircut, no problem Example #3 call_user_func(3) using namespace name <?php namespace Foobar; class Foo { static public function test() { print "Hello world! "; } } call_user_func(__NAMESPACE__ .'Foo::test'); // As of PHP 5.3.0 call_user_func(array(__NAMESPACE__ .'Foo', 'test')); // As of PHP 5.3.0 ?> The above example will output: Hello world! Hello world! Example #4 Using a class method with call_user_func(3) <?php class myclass { static function say_hello() { echo "Hello! "; } } $classname = "myclass"; call_user_func(array($classname, 'say_hello')); call_user_func($classname .'::say_hello'); // As of 5.2.3 $myobject = new myclass(); call_user_func(array($myobject, 'say_hello')); ?> The above example will output: Hello! Hello! Hello! Example #5 Using lambda function with call_user_func(3) <?php call_user_func(function($arg) { print "[$arg] "; }, 'test'); /* As of PHP 5.3.0 */ ?> The above example will output: [test] NOTES
Note Callbacks registered with functions such as call_user_func(3) and call_user_func_array(3) will not be called if there is an uncaught exception thrown in a previous callback. SEE ALSO
call_user_func_array(3), is_callable(3), information about the callback type, ReflectionFunction::invoke, ReflectionMethod::invoke. PHP Documentation Group CALL_USER_FUNC(3)
All times are GMT -4. The time now is 01:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy