BealgeBone unexport gpio script

This is a simple bash script, that took way to long to get correct, to unexport all the of exported gpio pins on your BeagleBone board at once.

#!/bin/bash
GPIO=/sys/class/gpio/*
UEXT=/sys/class/gpio/unexport

for file in $GPIO
do
  if [[ $file =~ (.*)(gpio)([0-9]+) ]]
  then
    echo "unexporting gpio${BASH_REMATCH[3]}"
    echo "${BASH_REMATCH[3]}" > $UEXT
  fi
done
Share

Leave a Reply

Your email address will not be published. Required fields are marked *