#!/bin/bash # findhal # written by count_zero # distributed under the GPL v2 # (Really) Quick Bash Script to find device sections in the output of `lshal` # Usage: findhal limit=`lshal | grep -i -o $1 | sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' | wc -l` line=1 until [ "$line" == $(( limit + 1 )) ] do search=`lshal | grep -i -o $1 | sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' | sed -n "$line s/.*/&/p"` lshal | sed -e '/./{H;$!d;}' -e "x;/$search/!d;" line=$(( line + 1 )) done