BASH 23
FindLargeFiles By allan on 9th September 2025 07:42:58 AM
  1. #!/bin/bash
  2. # ln -s /home/allan/Workspace/AMG/DEV/files/findLargeFiles.sh ~/bin/fLarge
  3. # set -x0
  4.  
  5. progname=`basename $0`
  6. log=`basename $progname sh`log
  7. fs=$1
  8.  
  9. if [ $fs = "/" ]
  10.   then
  11.     fsname="root"
  12.   else
  13.     fsname=$fs
  14. fi
  15.  
  16. file="/tmp/${HOSTNAME}_${fsname}_"`date +"%Y%m%d"`".log" ; \
  17. #exclude=(boot export dev mnt proc run srv sys u01 u02 u03 u04 u05 u06)
  18.  
  19. function findLargeFiles(){
  20. cd $fs
  21.   find . -type d \( \
  22.     -path ./boot  \
  23.     -o -path ./srv \
  24.     -o -path ./export \
  25.     -o -path ./dev \
  26.     -o -path ./mnt \
  27.     -o -path ./proc \
  28.     -o -path ./run \
  29.     -o -path ./sys \
  30.     -o -path ./u01 \
  31.     -o -path ./u02 \
  32.     -o -path ./u03 \
  33.     -o -path ./u04 \
  34.     -o -path ./u05 \
  35.     -o -path ./u06 \) \
  36.     -prune -o -printf '%s %p\n' \
  37.     | sort -nr | head -1000 \
  38.     > $file ; \
  39.     chmod 777 $file
  40. }
  41.  
  42. findLargeFiles

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.