Brian: > > A=$(lsusb | grep -i 'Stylus Color 740') > if [ -z "$A" ]; then > systemctl stop cups.service cups.socket cups.path > fi > > (No sniggering at the back, please. I'm aware of the deficiencies in the > logic. Improvements are welcome).
I would have phrased it something like this: if ! lsusb | grep -qi 'Stylus Color 740'; then systemctl stop cups.service cups.socket cups.path fi grep exits with > 0 if it doesn't find your pattern. In this case you can use -q to prevent grep from printing matching lines on stdout. Ugly one-liner: lsusb | grep -qi 'Stylus Color 740' || systemctl stop cups.service cups.socket cups.path "EITHER grep finds something OR I want to shut down Cups." J. -- I have been manipulated and permanently distorted. [Agree] [Disagree] <http://www.slowlydownward.com/NODATA/data_enter2.html>
signature.asc
Description: Digital signature