how to compare a variable with a number?
the code is as below:
if [ $i -le $tnum ] ; then if [ $t -ne 0 ]; then {array[$tnum]}=$t tnum=$((tnum+1)) fi else {array[$tnum]}=$t tnum=$((tnum+1)) fi bash : error :./omrprac1.sh: line 14: [: 0: unary operator expected ./omrprac1.sh: line 14: [: 0: unary operator expected ./omrprac1.sh: line 14: [: 0: unary operator expected ./omrprac1.sh: line 14: [: 0: unary operator expected how can i compare a a variable t with number zero? |
Tricky, there's only 11 lines there .... ;)
Try it this way (inc indentations; use code tags) Code:
#!/bin/bash http://www.tldp.org/LDP/abs/html/ HTH |
Hey The array is not set the the value i want:
the below is the code:
#!/bin/bash i=1 tnum=1 while read line do t=$(echo "$line" | awk '{print $3}') if [ $i -ne $tnum ] then if [ $t -ne 0 ] then {array[$tnum]}=$t echo ${array[$tnum]} #not showing the value tnum=$((tnum+1)) fi else {array[$tnum]}=$t echo ${array[$tnum]} #not showing the value tnum=$((tnum+1)) fi echo ${array1[$tnum]} #not showing the v done < <(grep '^ID' /home/admin/cdat.txt) please let me know why the array is not echoed when i run the program.. it is not taking at all... |
All times are GMT -5. The time now is 07:44 AM. |