Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is there a linux command that I can issue to look for files whose size is larger than 1GB?

Posted on 2010-08-12
10
Medium Priority
?
403 Views
Last Modified: 2013-12-16
I need to monitor my linux system for files that are larger than 1GB.  Is there a command line that I can issue to do that?  And does it run pretty fast?  
0
Comment
Question by:dgintz1217
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 7

Expert Comment

by:jhp333
ID: 33425113
find . -size 1G -print

where . is the starting directory.
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 33425248
Above will show only 1GB files, not all larger than 1GB.
Try similar one:
find . -size +1G
(-print option is not necessary - it's used by default if no other expression is given).
0
 

Author Comment

by:dgintz1217
ID: 33425268
jhp333- could you help me out by putting that into a bash script that would list out the actual files (like with an ls -l) that only shows the file paths to files that are of that size.  when i ran the command above it gave me the directories as well:

[root@hotel:/var/spool]$find . -size 1G -print
.
./mail
./mail/airlink
./mail/root
./clientmqueue
./clientmqueue/dfn9TEU155002839
./cups
./cups/tmp
./at
./at/.SEQ
./at/a0000101392294
./at/spool
./mqueue
./anacron
./anacron/cron.monthly
./anacron/cron.daily
./anacron/cron.weekly
./repackage
./vbox
./bittorrent
./squid
./cron
./cron/al1
./cron/root
./lpd

And what i'm trying to get is something like this:

[root@hotel:/var/spool]$ls -l ./mail/airlink
-rw-rw---- 1 airlink mail 263336 2010-06-09 08:33 ./mail/airlink
[root@hotel:/var/spool]$ls -l ./mail/root
-rw------- 1 root root 259165938 2010-08-12 17:15 ./mail/root

Also, you can see by the above that those files are NOT 1G+ - did I do something wrong in my command?

Thanks!
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
LVL 7

Assisted Solution

by:jhp333
jhp333 earned 1332 total points
ID: 33425315
oklit is right. You need + befor 1G
And for the output format you wanted,

find . -size +1G -ls

Not sure why it shows files smaller than 1GB, it shouldn't.
0
 

Author Comment

by:dgintz1217
ID: 33425541
Yes, the + did the trick.  say, as a favor, can i ask if you could put together a small bash script here such that the output would not just be the file names, but an "ls -l" of the file names?
0
 
LVL 7

Accepted Solution

by:
jhp333 earned 1332 total points
ID: 33425639
I already answered above for your "ls -l" question.

And for the incorrect size, try this:

find . -size +2097152 -ls

2097152 is number of blocks(512-byte block) for 1GB.
0
 
LVL 2

Assisted Solution

by:ramkumar_rkin
ramkumar_rkin earned 668 total points
ID: 33426866
Try this

find / -type f -size +1048576k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Output :
 find / -type f -size +1048576k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
/proc/kcore: 8.1G
find: /proc/18573/task: No such file or directory
/rs08/u01/app/oragrid/p3731593_10205_Linux-x86-64.zip: 1.1G
0
 

Author Closing Comment

by:dgintz1217
ID: 33428987
This was a very great help and exactly what I was looking for!  Thanks!!!!
0
 
LVL 7

Expert Comment

by:jhp333
ID: 33432069
find utility itself has -printf option for formatting the output. You don't need awk for output formatting.

For example, to get the full path and the size, instead of -ls, use:
-printf "%p %s\n"

0
 

Author Comment

by:dgintz1217
ID: 33438490
Cool.  Didn't know that.  Thanks!
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question