How echo variable x and y outside "while" in SHELL script:
#!/bin/bash
x=1
y=1
mysql -e "show tables like 'do97_%';" --host=localhost --skip-column-names -u login999il --password=e9999999999df54y basenamel | while read tables; do
mysql -e "SELECT id, tolbox, del_time FROM $tables WHERE deleted=0 ORDER BY create_time DESC LIMIT 0" --host=localhost --skip-column-names -u login999il --password=e9999999999df54y basenamel | while read id tolbox del_time; do
y=$(($y+1))
done
x=$(($x+1))
done
# how get this variable outside "WHILE"
echo $x
echo $y
when I run this script x and y echo empty space, when i echo this inside "while" operator it work but how get variable outside?