Added function to write shell script with extract tree stats command