Search Results

Search: Posts Made By: Ghassen
1,100
Posted By Yoda
The reason is when you pipe the file to a while...
The reason is when you pipe the file to a while loop, it actually gets executed in a sub-shell:-
cat $1 | while read line
So the scope of the variable sum value is within the while loop. This is...
1,100
Posted By Scott
such as it is (although there's a program for...
such as it is (although there's a program for that, called wc :)):

sum=0
while read line; do
sum=$((sum + 1))
done < $1
echo $sum


$ cat -n myFile
1 this
2 is
3 a
...
Showing results 1 to 2 of 2

 
All times are GMT -4. The time now is 01:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy