[[ $(find /path/to/file -type f -size +51200c 2>/dev/null) ]] && echo true || echo false
find
takes care two things at once: checks if file exists and size is greater than 51200./dev/null
to hide the error message if the file doesn't exist.find
will be non-blank if the file matched both conditions, otherwise it will be blank[[ ... ]]
evaluates to true or false if the output of find
is non-blank or blank, respectivelyYou can use this in if
conditions like:
if [[ $(find /path/to/file -type f -size +51200c 2>/dev/null) ]]; do
somecmd
fi