login|Register
Forum > Debian
Post|
看871|回0|Favorite
jwgorman 看全部
2024-2-19 06:44:29

code:

  1. #!/bin/bash

  2. # Split the first command line argument by '/'
  3. IFS='/' read -r -a items <<< "$1"

  4. # Iterate through the items
  5. for ((i=0; i<${#items[@]}; i++)); do
  6.     # Check if the current item matches the pattern 'usb' followed by one or more digits
  7.     if [[ ${items[$i]} =~ ^usb[0-9]+$ ]]; then
  8.         # Print the next item in the list and exit the loop
  9.         echo "${items[$((i+1))]}"
  10.         break
  11.     fi
  12. done
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"

OrangePi En

Powered by Discuz! X3.4

homepage|Simple edition|Touch edition|PC