LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2003, 06:51 AM   #1
fintan
LQ Newbie
 
Registered: Aug 2003
Distribution: gentoo, redhat
Posts: 12

Rep: Reputation: 0
listing large files


How do you list files that are larger than 1 Gig ? Thanks

fintan.
 
Old 11-06-2003, 09:01 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Are you wanting to only list files larger than 1GB or just asking how to list them generally speaking?

ls -al would list all files in a directory, no matter the size.
 
Old 11-06-2003, 09:15 AM   #3
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 457

Rep: Reputation: 41
If you want to "find" them, well, there is always find :-)

If a GB is 1024^2 kilobytes, "find . -type f -size +1048576k" would do as you like for the current location, down. Read "man find" for more information or fine-tuning.
 
Old 11-06-2003, 09:30 AM   #4
fintan
LQ Newbie
 
Registered: Aug 2003
Distribution: gentoo, redhat
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, I got a two hundred gig hard drive and I just wanted to do a bit of a clean up.

Last edited by fintan; 11-06-2003 at 09:36 AM.
 
Old 11-06-2003, 10:54 AM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 35
Try a shell script - snippet below. This works for the whole directory tree
Code:
while getopts 2>/dev/null r c
do
  case $c in
    r) find . -type f | xargs ls -la |cut -c35-45,59-120 \
       | sort -r -n  ; exit 0 ;;
   \?) echo "\nUsage: $0 [-r]
       list the byte count and name of files in current dir sorted by size
       -r recursively lists all of the subdirectories as well" >&2
        exit 2;;
  esac
done
 
Old 11-06-2003, 11:59 AM   #6
fintan
LQ Newbie
 
Registered: Aug 2003
Distribution: gentoo, redhat
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for the snippit but I couldn't get any out put from it.
The "find . -type f -size +1048576k" worked with a "/" instead of "."
"find / -type f -size +1048576k"
 
Old 11-06-2003, 12:09 PM   #7
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 35
Save the snippet to spacehog.sh (or some other file name )
chmod +x spacehog.sh
. spacehog - r

It needs a -r after the script name - for a recursive search. It is just part of a script.
 
Old 11-06-2003, 12:40 PM   #8
fintan
LQ Newbie
 
Registered: Aug 2003
Distribution: gentoo, redhat
Posts: 12

Original Poster
Rep: Reputation: 0
Worked like a charm thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
listing all files of a certain user X-GhoSt Linux - General 1 10-22-2005 04:22 AM
listing files in to an array sujith_deva Programming 1 12-12-2004 03:14 PM
listing files in a directory Linh Programming 7 05-17-2004 05:35 AM
Listing files from within a C program? PsychosisNode Programming 4 11-16-2003 11:40 AM
listing files in apache im1crazyassmofo Linux - Software 0 07-27-2003 06:05 PM


All times are GMT -5. The time now is 05:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration