Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2014
    Posts
    1

    Unanswered: To list 50 largest files along with FULL PATH and owner

    Hi,
    Below command list top largest 50 files regardless of subfolders.

    $ls -lR /root/home | sort +4 -5nr | head -50

    Current Result:
    -rw-r--r-- 1 john dpst 192954384 Nov 7 07:36 filenxx1.gz
    -rw-rw---- 1 paul dpst 192188934 Nov 18 10:10 filenyyy1.mov

    My new requirement is to get its "owner" and its "full path"

    Result - example:
    john /home/dev/proj/filenxx1.gz
    paul /home/dev/proj/filenyyy1.mov

    Please help me how to loop the list of 50 files and to get is owner and full path using "find" or any command in unix.

    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    count=0
    du -a /home |sort -r -n  >workfile
    while read size file
    do
    if [ ! -d $file ]
        ls -l $file
        count=`expr $count + 1`
    fi
    if [ $count -gt 50 ]
       exit
    fi
    done<workfile
    echo less than 50 files
    I haven't tested this, and I presumed that you did not want to include the operating system files.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •