#!/bin/bash serials=`arduino-cli board list | grep USB | awk '{print $1}'` # echo ${serials} if [ -z "${serials}" ]; then echo "No device connected." exit fi ## if multiple ports found, try uploading to all ports. seriallist=($serials) ## print the list # echo ${seriallist[@]} for ser in ${seriallist[@]} ; do echo ${ser} arduino-cli upload --fqbn esp32:esp32:m5stick-c -p ${ser} -i ../M5StickCPlus_FactoryTest2022.ino.bin done