79535642

Date: 2025-03-26 07:06:40
Score: 2
Natty:
Report link

This is getting kind of old, but the OP's question caught my eye. Following is a script I've been using for a while that works well, and while it reads "lines", the "lines" can be referenced as "words". Maybe this is cheating (???), but it answers the question affirmatively.

#!/usr/bin/env bash

POLLMNT_LOG='/home/pi/pollmnt.log'

/usr/bin/findmnt -n --poll=umount,mount --target /boot/firmware |
while read firstword otherwords; do
#          ^^^^^^^^^ ^^^^^^^^^^
    case "$firstword" in
        umount)
            echo -e "\n\n ===> case: umount" >> $POLLMNT_LOG
            dmesg --ctime --human >> $POLLMNT_LOG
            mount -a
            ;;
        mount)
            echo -e "\n\n ===> case: mount" >> $POLLMNT_LOG
            dmesg --ctime --human >> $POLLMNT_LOG
            ;;
        *)
            echo -e "\n\n ===> case: * (UNEXPECTED)" >> $POLLMNTLOG
            ;;
    esac
done

Inspiration came from [this article](https://linuxize.com/post/bash-read/) on linuxize.com

Reasons:
  • Blacklisted phrase (1): this article
  • Blacklisted phrase (1): ???
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Seamus