I executed a script that printed out some data. It looks something like this:
pi@pitwo:~/testing $ python3 scripts/test.py
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
What I'm looking for is a bash command way to count the length of the data.
I could write a script that does some counting, or even count it by hand since it's short, but I'd like to get your input on how you linux/unix veterans would do this.
print(len(my_array))into your python program. What if an array element is"1,2"? The general solution is to have a well-defined delimiter and count the items. It could be the space or the comma or the newline etc. And if the delimiter is allowed inside fields (see csv, json, etc) it gets complicated, it's more than just serially counting fields.