So I am trying to tell if the machine has a battery, then run different commands based on whether or not it does. Here's what I have so far:
upower -d >> /tmp/batstat if [ grep -F BAT0 /tmp/batstat ]; then echo "BAT0 PRESENT" >> /tmp/batstat else echo "NO BAT0" >> /tmp/batstat fi
However, this returns the error "bash: [: too many arguments" while writing NO BAT0 to /tmp/batstat as expected. Running only the grep works properly, so I don't understand why it doesn't work as an if condition.
If there is a better way to check for a battery, I am 100% open to it.