I build/keep several functions in my .profile file (see below).  They are
all simple enough to call at anytime.  Have fun....

     Function  Description
     --------------------     ------------------------------------
     findc          find files
     findl          find large files
     findn          find files created/accessed in the last day
     findo          find open files



function findc
{
find . -name "*${1}*" -print 2>/dev/null | more
}

function findl
{
  OPT_d="."
  OPT_s="1"
  OPT_n="38,12"
  while getopts d:ns:h option
  do
    case "${option}"
    in
       d)      OPT_d="${OPTARG}" ;;
       n)      OPT_n="63,60"     ;;
       s)      OPT_s="${OPTARG}" ;;
       h | \?) echo "usage: findl [-h] [-d starting directory] -n [-s
size_meg]"
               echo "       -d defaults to the current directory"
               echo "       -n default sort is by size, if -n is specified
then the sort is by path and name"
               echo "       -s list files greater than or equal to 'n' meg,
defaults to 1"
               return;;
    esac
  done
  DMY=$(echo "${OPT_s}" | tr "[0-9]" "[\0*10]")
  if [ ${#DMY} -ne 0 ]
  then
    echo "Invalid value for option -s"; return
  fi
  [ "${OPT_s}" = "" ] && v_size=1048576 || v_size=$((${OPT_s} * 1048576))
  find ${OPT_d} -size +${v_size}c -type file 2>/dev/null |
\
    xargs -n 20 ls -Fla {} 2>/dev/null |
\
    awk '{printf ("%10.10s %3.3s %-10.10s %-10.10s %12s %3.3s %2.2s %5.5s
%s %s %s %s\n",   \
      $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) }' 2>&1 |
\
    sort -k .${OPT_n}
}

function findn
{
  find . -name "*${1}*" -ctime -1 -type f -print | sort | while read F
  do
    echo "$(ls -Fla ${F}) $(fuser ${F} 2>/dev/null | cut -c1-60)"
  done | \
    awk '{printf ("%10.10s %3.3s %-10.10s %-10.10s %12s %3.3s %2.2s %5.5s
%s %s %s %s %s %s %s %s %s %s %s %s\n", \
      $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
$16, $17, $18, $19, $20) }' 2>&1 | sort -k .38,12
}

function findo
{
  find . -name "*${1}*" -ctime -1 -type f -print | sort | while read F
  do
    v_CNT=$(fuser ${F} 2>/dev/null | wc -w)
    if [ ${v_CNT} -ne 0 ]
    then
      echo "$(ls -Fla ${F}) $(fuser ${F} 2>/dev/null | cut -c1-60)"
    fi
  done | \
    awk '{printf ("%10.10s %3.3s %-10.10s %-10.10s %12s %3.3s %2.2s %5.5s
%s %s %s %s %s %s %s %s %s %s %s %s\n", \
      $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
$16, $17, $18, $19, $20) }' 2>&1 | sort -k .38,12
}

Brian P. MacLean
Oracle DBA, OCP8i



                                                                                       
                             
                    "Seema Singh"                                                      
                             
                    <oracledbam@ho       To:     Multiple recipients of list ORACLE-L 
<[EMAIL PROTECTED]>        
                    tmail.com>           cc:                                           
                             
                    Sent by:             Subject:     WHich Unix command               
                             
                    [EMAIL PROTECTED]                                                     
                             
                    om                                                                 
                             
                                                                                       
                             
                                                                                       
                             
                    04/29/02 12:08                                                     
                             
                    PM                                                                 
                             
                    Please respond                                                     
                             
                    to ORACLE-L                                                        
                             
                                                                                       
                             
                                                                                       
                             




Hi
Which unix command(On Solaris) is used to find latest biggest files on
whole
server?
or
Which unix command(On Solaris) is used to find latest biggest files on
particular disk partition?
Thx
-seema



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Seema Singh
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to