Quote:
Originally Posted by druuna
Not sure why you need an array for this but have a look at this:
Code:
#!/bin/bash
for i in {1..5}
do
count[$i]=$i # fill count[X] with X
(( count[$i]++ )) # add one to count[X]
done
# show array content
echo ${count[1]}
echo ${count[2]}
echo ${count[3]}
echo ${count[4]}
echo ${count[5]}
Example run:
Code:
$ ./foo.sh
2
3
4
5
6
|
Thank you, I have a condition to do it.
for i in {1..15}
do
cut -d';' --fields="$i" tehrasht.txt>m.txt
while read LINE
do
if [ $LINE == '1' ];then
((count["$i"]++))
fi
done < m.txt
echo ${count[$i]}
count[$i]=0
done
Now, It show the output, but before it,the error is shown:
./obu.txt: line 6: [: too many arguments