#!/bin/bashs="1 1 1 1 1 1 -1 -1 -1 -1 -1 10 10 10 10 10"awk '{a=0;for(i=1;i<=NF;i++) { if($i=="1") {a++} };print a}' <<< "$s"
Standard input is empty
6
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!