#!/bin/bash
id_re='id:[[:space:]]*([[:digit:]]+)'  # assign regex to variable
stylus_ids=( )                         # make an empty array to store ids in

while IFS= read -r line; do
  [[ $line = *stylus* ]] || continue   # skip lines without "stylus"
  [[ $line =~ $id_re ]] || continue    # match against regex, or skip the line otherwise
  stylus_id=${BASH_REMATCH[1]}         # take the match group from the regex
  echo "# Command for line $line"
  printf '%q ' xsetwacom --set "$stylus_id" area 123 123 123 123 </dev/null; echo
  echo
done
