Tips tagged find


9

Tip #171   Duplicate directory tree

The following command creates in the /usr/project directory, a copy of the current working directory structure:

Read more »

9

Tip #363   Finding log files X number of days old and deleteing them.

This is a script that I recently wrote to find the logs of my IDP that were over 90 days old and delete them.

The script is pretty much self explanatory.

Read more »

7

Tip #307   Delete old files

Use find by time to delete files more than x days old. For example the command below will delete files more than one day old:

find . -mtime +1 -exec rm {} \; Read more »

7

Tip #796   Find files by mime-type

Use this command to find files of a given mime-type. For example to find all PNG images in a directory or below:

Read more »

6

Tip #165   Directories and its size

which directories and trees take up all the diskspace?
du -sm $(find /start/dir/* -type d -maxdepth 1 -xdev) | sort -g

If you want more human readable output try:
du -ha /var | sort -n -r | head -n 10

you want to see ALL directories in the tree
find $1 -type d | xargs du -sm | sort -g

To show all directories size including sub directories, type

du -h

To calculate the current directory size you are in (-s stand for summary)

du -sh

To show all the 1 level sub directories size (which you are not interested at sub sub directories.)

du -sh *

To show the size of specific directory

du -sh /home

To show the size of all sub directories of a specific directory

du -sh /home/* Read more »

6

Tip #850   Checksum directory recursively

Do a sha256sum of an entire directory name directory and check for integrity.
Modifying the IFS variable is necessary for filename with space.

Read more »

6

Tip #208   Pipe files to an archive

If you want to select specifically the files to add to an archive you can pipe the output from find (or any command that gives a list of files) to cpio:

Read more »