#! /bin/sh # Copyright 2009, Chris Cox # Copyright 2009, Sterling Commerce, Inc. # # This software is licensed under the GNU Public License Version 2.0 # # Display /sys attributes showpathnames="" bold="" b="" n="" while [ $# -gt 0 ]; do case "$1" in -b) # show attribute values in bold b=`tput bold` n=`tput sgr0` ;; -p) # Show pathnames showpathnames=1 ;; --help|-*) echo "Usage: showsysfs [ -b | -p ]" >&2 echo " -p = show full pathnames" >&2 echo " -b = show attribute values in bold" >&2 exit 1 ;; *) break ;; esac shift done dirs="$*" dirs=${dirs:=/sys} for dir in $dirs; do find "$dir" \( -name 'debug' -o -name 'tracing' -o -name 'nvmem' -o -name '*_raw' -o -name '*_pipe' -o -name 'apparmor' -o -name 'events' \) -prune -o -print0 2>/dev/null | if [ "$showpathnames" ]; then xargs -n1 -0 grep '.' /dev/null 2>/dev/null else xargs -n1 -t -0 grep '.' /dev/null 2>&1 | sed -e 's,grep . /dev/null ,,' -e 's,[^/]*/,| ,g' \ -e 's,\([^ /|]\),\\- \1,' fi | sed "s/:\([^:][^:]*\)$/: $b\1$n/" done