One liner workaround:
find -size +10G | grep ".*" > file.log || (rm file.log; echo "Can't find anything")
Or:
find -size +10G | grep ".*" > file.log || rm file.log
Note that find
returns 1 (False) when files are not processed correctly for any reason, so I suggest using something like:
#!/bin/bash
RESULTS=$(find /path -size +1G)
if [ -n "$RESULTS" ];
then
echo "$RESULTS" > /path/file.log
fi
First run the find
and put the results in a variable, then if the variable contained anything save that into a log file.