The Power of find


Find all files for which the user <user> (member of <group>) has no permisson to read:

find . ! \( -user <user> -perm -u+r \) \
       -and ! \( -group <group> -perm -g+r \) \
       -and ! -perm -o+r

Find all files for which the user <user> (member of <group>) has not at least the permisson to read and to write and which are not lying under the directory "./some_path/". Set read and write permission for the owner on every matching file:

find . ! \( -user <user> -perm -u+rw \) \
       ! \( -group <group> -perm -g+rw \) ! -perm -o+rw \
       ! -path './some_path/*' -exec chmod u+rw {} \; -print

Renaming a bunch of files by letting sed construct a command piped to and executed by a shell:

find . -maxdepth 1 -name "prefix*.txt" -print \
     | sed -n -e 's:\.\/\(prefix\(.*\)\.txt\):mv \1 newprefix\2.txt:p' \
     | sh

Links to some interesting articels on find

line
linux logo Powered by Apache
line
This site maintained by:
lukas.zimmermann@unibas.ch
My public PGP key
last updated: 2009-06-11 Valid CSS! Valid XHTML 1.0 Strict