Fuser alternative OR running fuser on a script

Hi,

Not sure whether there is a fuser alternative or any better way to check for file in use or not.

I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of one.

$: fuser /db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf
/db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf:     3559o    3157o    3040o    2923o   28148o
$: fuser /db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf | awk '{ print NF }'
/db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf: ooooo
5
$: fuser /db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf | awk '{ print $1 }'
/db/oltp/index/oltp_dwh_ind_fact_prs_phlegfi201202_01.dbf: ooooo
3559

.

I decided to write a script below that re-directs the output of fuser and then using awk to check for field2=$2 is zero/null, if it is then the file is not in use, otherwise it is in use and should no be removed.

Currently the script is as below:

#!/bin/ksh

ls -1tr /db/oltp/data/oltp_dwh_dat_fact_prs_ph*.dbf | grep -v 2014 > check_files.tmp.00
echo
echo "Running fuser of data ..."
while read data
do
   fuser $data 1>z.out 2>&1

   if [[ -z "`awk '{ print $2 }' z.out`" ]] ; then
      echo "$data = not in use"
   else
      echo "$data = file in use"
   fi
done < check_files.tmp.00

I just want some feedback on whether this is the best solution for checking file in user using fuser before removing.

The link below show a neat trick with fuser,

http://www.c0t0d0s0.org/archives/4228-Less-known-Solaris-Features-fuser.html

ps -o pid,args -p "$(fuser /mnt/application 2>/dev/null)"

but I am not really interested on what process is in use of the file. Also, it gives an error if the file is not in use unless I do a 2>/dev/null on the ps.