|
- #!/bin/bash
- # Split the first command line argument by '/'
- IFS='/' read -r -a items <<< "$1"
- # Iterate through the items
- for ((i=0; i<${#items[@]}; i++)); do
- # Check if the current item matches the pattern 'usb' followed by one or more digits
- if [[ ${items[$i]} =~ ^usb[0-9]+$ ]]; then
- # Print the next item in the list and exit the loop
- echo "${items[$((i+1))]}"
- break
- fi
- done
Copy code I was able to get static USB ports on an Orange Zero Pi with adding a udev rule refencing the script above like: ACTION=="add", KERNEL=="ttyUSB[0-9]*", PROGRAM="/etc/udev/rules.d/usb-parse-devpath.sh %p", SYMLINK+="ttyUSB_%c"
|
|