I need to use a find script to find files of a certain type then I would like to check if they are being accessed and if they are clear the contents otherwise remove the file. I'm ok with the find part but should I pipe the output to some kind of If statement.
If so, and if you have the lsof utility at hand, you could do:
find ./ -name "*.log" -type f -mtime +1 | while read file ; do lsof $file >/dev/null || >$file; done
lsof returns a "false" returnconde if the file is not open, so we use "||" here.