Uncategorized

Unix Useful

Remove Files Older than x Days

Unix remove log files older than x days..

Type : find /path/to/files* -mtime +5 -exec rm {} \;

Find Size of Directories

To find the size of a set of directories :-

Type : du -sh .  < current location / directory > reports size in MB/

i.e. cd /data/landing

Type : du-sh * << size of all directories i.e.

[root@ocvmdevace01-bdcsce-1 landing]# du -sh *

8.0G    CRC

28M     ftmclient

4.1G    INSIGHTS

50M     LIVEAPPS

1.8M    METADATA

100K    migration

49G     MR2

132K    RMS

 Find Size of Files Sorted

This will list size of files ascending in a directory

Type : du -sh * | sort -n -k 1

Find Size of Files Sorted – Recursive

This will list files by size in recursive directories

Type : find . -type f -exec du -sh {} \; | sort -n -k 1

 

Leave a Reply

Your email address will not be published. Required fields are marked *