Difference between revisions of "Find"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 19: Line 19:
 
= find files by content =
 
= find files by content =
 
To find files by content you do not use find, but [[grep]].
 
To find files by content you do not use find, but [[grep]].
 +
 +
= Do something with the file =
 +
find . -name '*.mp3' -exec echo "Do something with the file" {} \;
  
 
= See also =
 
= See also =
 
* [http://man-wiki.net/index.php/1:find find's man page]
 
* [http://man-wiki.net/index.php/1:find find's man page]

Revision as of 07:04, 15 November 2010

Find allows you to find files, e.g.

find by time

find files older than ...

To find files in folder that are older than 5 days use

find folder -ctime +5 -exec ls {} \;

To find how old a file is, use the command stat.

file modification

To find files whose content has been modified 1 days or shorter ago use

find . -mtime -1

To find files whose content has been modified 1 days or longer ago use

find . -mtime +1

find files that have content

find -not -empty -iname "foo*"

find files by content

To find files by content you do not use find, but grep.

Do something with the file

find . -name '*.mp3' -exec echo "Do something with the file" {} \;

See also