In Analyzing Scripts webpage of TLDP, the following code is provided for analysis:
export SUM=0
for f in $(find src -name "*.java"); do
export SUM=$(($SUM + $(wc -l $f | awk '{ print $1 }')))
done
echo $SUM
I understand that it calculates the sum of the number of lines of all *.java files in the directory src
. What I do not understand is the reason for using the export
keyword, which is described thus:
The export command makes available variables to all child processes of the running script or shell.
Since SUM
is never accessed by a child process, is there any reason for exporting it?