Below is the shell script to connect device through wifi (ADB over wifi). Save this file as connect-device.sh and you can directly execute as shell script.
#!/bin/sh
./adb.exe shell ip route > addrs.txt
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
./adb.exe tcpip 5555
./adb.exe connect $ip_addrs:5555
Below is the shell script to connect device through wifi (ADB over wifi). Save this file as connect-device.sh and you can directly execute as shell script.
#!/bin/sh
./adb.exe shell ip route > addrs.txt
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
./adb.exe tcpip 5555
./adb.exe connect $ip_addrs:5555