I am trying to find all folders with a certain name. I am able to do this with the command find /path/to/look/in/ -type d | grep .texturedata
No need to grep
output of find
to look for specific directory name. -name
option of find
will do the same job.
find /path/to/look/in/ -type d -name '.texturedata'
I would like it to stop at .texturedata
-prune
option is quite suitable for this requirement
find /path/to/look/in/ -type d -name '.texturedata' -prune
I have hundreds of these paths and would like to lock them down by piping the output of grep into chmod 000
Try using find
with -exec
option
find /path/to/look/in/ -type d -name '.texturedata' -exec chmod 000 {} \; -prune
More efficient approach would be to pipe output of find
using xargs
find /path/to/look/in/ -type d -name '.texturedata' -prune -print0 | xargs -0 chmod 000
TEST
$ tree -pa
.
|-- [drwxrwxrwx] .texturedata
| `-- [drwxrwxrwx] .texturedata
|-- [drwxrwxrwx] dir1
| |-- [drwxrwxrwx] .texturedata
| | `-- [-rwxrwxrwx] file2
| `-- [drwxrwxrwx] dir11
| `-- [-rwxrwxrwx] file111
|-- [drwxrwxrwx] dir2
| `-- [drwxrwxrwx] .texturedata
| `-- [-rwxrwxrwx] file3
|-- [drwxrwxrwx] dir3
| `-- [-rwxrwxrwx] file4
`-- [-rwxrwxrwx] file1
8 directories, 5 files
$ find . -type d -name '.texturedata' -prune -print0 | xargs -0 chmod 000
$ tree -pa
.
|-- [d---------] .texturedata [error opening dir]
|-- [drwxrwxrwx] dir1
| |-- [d---------] .texturedata [error opening dir]
| `-- [drwxrwxrwx] dir11
| `-- [-rwxrwxrwx] file111
|-- [drwxrwxrwx] dir2
| `-- [d---------] .texturedata [error opening dir]
|-- [drwxrwxrwx] dir3
| `-- [-rwxrwxrwx] file4
`-- [-rwxrwxrwx] file1
7 directories, 3 files