Tips tagged find


13

Tip #209   Directory Tree

The following alias will print the directory structure from the current directory in tree format.

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 »

10

Tip #199   Find files by modified time

When specifying time with find options such as -mmin (minutes) or -mtime (24 hour periods, starting from now), you can specify a number n to mean exactly n, -n to mean less than n, and +n to mean more than n. 2 For example:

Read more »

10

Tip #190   dos2unix all files in a directory

dos2unix requires the name of an input and output file so it can be hard to run on a list of files. The following gets around this and will run dos2unix on all files in a directory:

Read more »

18

Tip #181   Remove empty directories

To remove empty directories (even if filenames or dirnames contain spaces or weird characters) from a tree you can do:

Read more »

20

Tip #173   Count files by type

To find out the number of files of each type in your current directory try the following:

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 »

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 »

14

Tip #147   Find and Grep

Find all files with given name (you can use Bash expansion if you'd like), and Grep for a phrase:
Read more »