Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Thank you very much ! Actually that was my typo just now :/ it was correct in my system. Commented May 4, 2020 at 16:52
  • 1
    Or (( sum += arr[i] )) Commented May 4, 2020 at 16:52
  • @АндрейОганов If one of the answers solved your issue, please take a moment to accept it by clicking on the checkmark on the left. That will mark the question as answered and is the way that thanks are conveyed on the Stack Exchange sites. Commented May 4, 2020 at 16:57
  • Thank you very much ! So, what's wrong in this ? sum=0 for i in "${arr[@]}" do if (( "i" -gt 0 )); then sum =$psum+"$i" elif (( "i" -lt 0 )); then sum$nsum+"$i" fi done echo "positive = $psum" echo "negative = $nsum" Commented May 4, 2020 at 17:32
  • Thank you ! And how can I do it right ? Commented May 4, 2020 at 17:47