I am trying to get a quick script together to check a file system prior to running resize2fs.
#!/bin/bash
var2=$(dumpe2fs -h /dev/mapper/mylv | grep "Filesystem state:")
var1=test
echo $var1
echo $var2
if [ "$var2" = "Filesystem state: clean" ];
then
echo "clean"
else
echo "dirty"
fi
My results
Server1:~ # ./filesystest.sh
dumpe2fs 1.38 (30-Jun-2005)
test
Filesystem state: clean
dirty
It seems even though var2 is in fact "Filesystem state: clean" it still shows up false.
echo "$var2"(with quotes). Perhaps there are other characters in the output, not showing (e.g. double spaces).=(the POSIX-compliant syntax) is more correct than==(an extension added in bash only).