Difference between revisions of "Find"

From Linuxintro
imported>ThorstenStaerk
(New page: Find allows you to find files, e.g. find files older than find <Ordner> -ctime +5 -exec ls {} \;)
 
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
Find allows you to find files, e.g.
 
Find allows you to find files, e.g.
  
find files older than
+
= find by name =
  find <Ordner> -ctime +5 -exec ls {} \;
+
To find a file in your current folder and its subfolders, even if they are symbolic links, use the command
 +
find -L -iname "*''foo''*"
 +
This command will find all files containing ''foo'' in their filename ignoring case sensitivity.
 +
 
 +
= find by time =
 +
 
 +
== find files older than... ==
 +
To find files in ''folder'' that have been changed more than ''1'' day ago use
 +
  find ''folder'' -ctime +1
 +
To find out how old a file is, use the [[command]] [[stat]].
 +
 
 +
== find files newer than... ==
 +
To find files in ''folder'' that have been changed less than ''1'' day ago use
 +
find ''folder'' -ctime -1
 +
To find out how old a file is, use the [[command]] [[stat]].
 +
 
 +
= 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 =
 +
* [http://www.manpagez.com/man/1/find/ find's man page]
 +
* [http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1 locate's man page]
 +
* [http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1 whereis' man page]
 +
* [http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1 which's man page]
 +
 
 +
[[Category:Command]]

Latest revision as of 10:06, 27 November 2021

Find allows you to find files, e.g.

find by name

To find a file in your current folder and its subfolders, even if they are symbolic links, use the command

find -L -iname "*foo*"

This command will find all files containing foo in their filename ignoring case sensitivity.

find by time

find files older than...

To find files in folder that have been changed more than 1 day ago use

find folder -ctime +1

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

find files newer than...

To find files in folder that have been changed less than 1 day ago use

find folder -ctime -1

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

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