HI:
one way:
#!/usr/bin/bash
a=0
FILE="myfile.txt"
cat $FILE | while read line
do
a=$(($a+1))
echo $a
#done < $FILE
done
echo "Final line count is: $a‍



two way:
#!/usr/bin/bash


a=0
FILE="myfile.txt"
 while read line
do
a=$(($a+1))
echo $a
done < $FILE


echo "Final line count is: $a"‍





On the one way: the variable $a  in while loop is not useful. The two way 
excute result is not equal








------------------
                                             




                                                               谢谢!     
                                                       崔志良

Reply via email to