I don't think it's the answer to my question....
Let me ask it in a different way....
If I want to do something like this:
Code:
echo 'yy' >/tmp/file1
if grep -q 'xx' /tmp/file1 ; then
if ! grep -q 'yy' /tmp/file1 ; then
rm /tmp/file1
fi
fi
ls -l /tmp/file1
I prefer to write it as a one-liner and I would expect this line to do the same
Code:
echo 'yy' >/tmp/file1
grep -q 'xx' /tmp/file1 && grep -q 'yy' /tmp/file1 || rm /tmp/file1
ls -l /tmp/file1
Somehow this isn't the case and I don't get why not....
Even if there is no 'xx' in the file, the file could still get deleted.
Isn't there a better explanation than the one on that site and yours (it may be my fault that I don't get it)
This one does work the same
Code:
echo 'yy' >/tmp/file1
if grep -q 'xx' /tmp/file1 ; then
grep -q 'yy' /tmp/file1 || rm /tmp/file1
fi
ls -l /tmp/file1