A
A
adm1nb3k2014-12-07 00:15:00
bash
adm1nb3k, 2014-12-07 00:15:00

Where am I wrong?

There is such a task:
Look at the function from the bash script:

counter ()  # takes one argument
{
  local let "c1+=$1"
  let "c2+=${1}*2"
}

Enter in the form below the line that the command echo "counters are $c1 and $c2" will display if it is in the script after ten calls to the counter function with parameters first 1, then 2, then 3, etc., the last call with parameter 10.
And now my answer:
for i in {1..10}; do counter $i; echo "counters are $c1 and $c2"; done;

Help, what am I doing wrong?! Or I do not understand .. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2015-01-14
@AlexTalker

Enter in the form below the line that the command echo "counters are $c1 and $c2" will display if it is in the script after ten calls to the counter function with parameters first 1, then 2, then 3, etc., the last call with parameter 10.

Or am I wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question