Differences

This shows you the differences between two versions of the page.


find [2016/02/19 20:11] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== find ======
  
 +  * [[findutils]]
 +  * [[xargs]]
 +
 +== Find only files ==
 +
 +<code>
 +find /dir -type f
 +</code>
 +
 +== Find only directories ==
 +
 +<code>
 +find /dir -type d
 +</code>
 +
 +== Match expression ==
 +
 +<code>
 +find /dir -name '*test*'
 +</code>
 +
 +== Find files matching an extension ==
 +
 +<code>
 +find /dir -name '*php'
 +</code>
 +
 +== Find files not matching a rule ==
 +
 +<code>
 +find /dir -! -name '*txt'
 +</code>
 +
 +== Find files less than a day old ==
 +
 +<code>
 +find /dir -mtime -1
 +</code>
 +
 +== sort the results even with print0 ==
 +
 +<code>
 +find /var/nas/sites -type d -maxdepth 1 -print0 | sort -z | xargs -0 -I {} echo {}
 +</code>
 +
 +== find directories but ignore dot directories ==
 +
 +<code>
 +find /var/nas/sites -mindepth 1 -maxdepth 1 -! -name '.*' -print
 +</code>
 +
 +== find files and run 'ls' on them ==
 +
 +<code>
 +find . -type f -ls
 +</code>
 +
 +== find empty files ==
 +
 +<code>
 +find . -type f -empty
 +</code>

Navigation
QR Code
QR Code find (generated for current page)