Ls -al / du


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ls -al / du
# 1  
Old 12-04-2014
Ls -al / du

// UNIX 6.1

I have /opt directory growing so fast, and /opt has a number of sub-directories.

Is there a way to display files larger than 100 MB on /opt and its sub-directories?

I like to have the file names, their sizes, and their filesystem path (/opt/xxx) in desc order.

Please advise.
# 2  
Old 12-04-2014
Code:
find /opt -type f -size +100M -exec ls -l  {} \;

This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 12-05-2014
Thank you!

Would it be possible to convert the size into MB and then sort them by descending order of the file size?

PHP Code:
-rwxrwxrwx    1 root     system      5602212 Nov 09 2013  /opt/IBM/ITM/BACKUP/messaging/v710/aix523/mq/hist/CERN.BPCH2AP2.H2PRD/QMEVENTH
-rwxrwxrwx    1 root     system       803880 Nov 09 2013  /opt/IBM/ITM/BACKUP/messaging/v710/aix523/mq/hist/CERN.BPCH2AP2.H2TRN/QMEVENTH
-rwxrwxrwx    1 root     system      1001818 Nov 09 2013  /opt/IBM/ITM/BACKUP/messaging/v710/aix523/mq/hist/CERN.BPCH2AP2.H2TRN/QMEVENTH.arc
-rwxrwxrwx    1 root     system     10483704 Nov 09 2013  /opt/IBM/ITM/BACKUP/messaging/v710/aix523/mq/hist/CERN.BPCH2AP2.H2TRN/QMEVENTH.old
-rwxrwxrwx    1 root     system       343228 Nov 09 2013  /opt/IBM/ITM/InstallITM/plugin/plugins/plugin_mq-comp_all-1.jar
-rwxr-xr-x    1 root     system        53254 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/awt_robot
-rwxr-xr-x    1 root     system       156668 Oct 25 2012  /opt/IBM/ITM/JRE/aix523/bin/classic/libjvm.so
-rwxr-xr-x    1 root     system        69031 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/headless/libmawt.a
-rwxr-xr-x    1 root     system       285592 Oct 25 2012  /opt/IBM/ITM/JRE/aix523/bin/ikeycmd
-rwxr-xr-x    1 root     system       285592 Oct 25 2012  /opt/IBM/ITM/JRE/aix523/bin/ikeyman
-rwxr-xr-x    1 root     system       181827 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/j9vm/libjvm.a
-rwxr-xr-x    1 root     system       156668 Oct 25 2012  /opt/IBM/ITM/JRE/aix523/bin/j9vm/libjvm.so
-rwxr-xr-x    1 root     system       295050 Oct 25 2012  /opt/IBM/ITM/JRE/aix523/bin/java
-rwxr-xr-x    1 root     system        56056 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/java.properties
-rwxr-xr-x    1 root     system        57566 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/java_ca.properties
-rwxr-xr-x    1 root     system        58936 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/java_cs.properties
-rwxr-xr-x    1 root     system        57807 Nov 29 2008  /opt/IBM/ITM/JRE/aix523/bin/java_de.properties
....... 
# 4  
Old 12-05-2014
Daniel,
is it the output of the find command? I ask this because the biggest file is ~10MB.

You mentioned UNIX 6.1, did you mean AIX 6.1? If so, then try:
Code:
find /opt -type f -size +100000000c -exec ls -l  {} \;

Quote:
Would it be possible to convert the size into MB and then sort them by descending order of the file size?
Yes, the above find command should print files greater than 100000000 bytes (~100MB). Then extend the find command like so
Code:
find /opt -type f -size +100000000c -exec ls -l  {} \; | sort -nrk5,5 | awk '{$5=$5/1024/1024}1'

Sample output (before sort & awk):
Code:
-rw-r-----   1 oracle   dba      104865792 Jan  1 00:00 ./example01.dbf
-rw-r-----   1 oracle   dba      513810432 Jan  1 00:00 ./system01.dbf
-rw-r-----   1 oracle   dba      272637952 Jan  1 00:00 ./sysaux01.dbf

Sample output (after sort & awk):
Code:
-rw-r----- 1 oracle dba 490.008 Jan  1 00:00 ./system01.dbf  # 490 MB
-rw-r----- 1 oracle dba 260.008 Jan  1 00:00 ./sysaux01.dbf  # 260 MB
-rw-r----- 1 oracle dba 100.008 Jan  1 00:00 ./example01.dbf # 100 MB

Hope this helps.
This User Gave Thanks to junior-helper For This Post:
# 5  
Old 12-05-2014
Thank you so much!!! It works great.
# 6  
Old 12-07-2014
Another option. I don't know if this works with AIX, but

Code:
du -sh $(find /opt -type f -size +10M) | sort -nr

produces these results (files larger than 10MB):
Code:
 59M	/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports.tar
 26M	/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/base.tar
 11M	/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/PortIndex

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question