Questions tagged [find]

search for files in a directory hierarchy

Find is used to look files in a directory hierarchy. You can refer to its manpage here.

Examples:

Look for all files on a server owned by user siegfried:

 find / -user siegfried

Find all files ending in php en remove them:

 find / *.php -exec rm '{}' \;
314 questions
6
votes
4 answers

How to find directory containing specific files or directories?

I'm looking for a one-line command that find multiple files or directories contained by a single directory. foo -> bar -> baz -> quux temp -> bar I'm looking to only find foo because it contains bar, baz, and quux, but not find temp. Due…
StephenG
  • 183
  • 1
  • 7
6
votes
2 answers

linux command line find escape question mark

For some reason I would like to delete all files names like "*.jpg?" (the filename is ending with a real ?) I tried this find /var/www/ -type f -name "*.jpg\?" and find /var/www/ -type f -name "*.jpg?" but this doesn't work how can i do that ?
Bouki
  • 115
  • 1
  • 3
  • 11
6
votes
6 answers

Get Size of All Folders in Directory

I want to get the size of all directories within a specific directory. I was thinking something like find . -type d -exec du -sh {} \; But that returns all directories recursively. How can I limit the depth?
Steve Robbins
  • 1,932
  • 5
  • 23
  • 26
6
votes
2 answers

How to count all subfolders in an directory?

How can I count how many folders (including subfolders) I have under an specific folder?
Max
  • 465
  • 2
  • 6
  • 11
6
votes
4 answers

How to tell if a file is older than 30 minutes on AIX?

I'd like to write a shell script in ksh or bash which exits with 1 if a specific file is older than 30 minutes. (Last modification time is older than half hour). It would be easy on a Linux or a modern unix, but I have to do it on AIX 5.2…
csadam
  • 188
  • 2
  • 8
6
votes
4 answers

Find the location of libmysqlclient.so.X file in Linux environments

I'm putting together a script that has a requirement of knowing libmysqlclient.so.[15|16|18] .so file. It's usually located in /usr/lib/ , /usr/lib64/ or a mysql/ subdirectory of the aforementioned directories. I have tried a few things. First of…
wrangler
  • 3,080
  • 5
  • 24
  • 20
6
votes
3 answers

Difficult to Delete Files in Linux

There's a lot of stuff about this on the Internet, but most of the examples there are contrived. How does one delete files that are really stubborn? e.g., $ find ./ -inum 167794 ./àKÈÿÿÿÿ@ $ find ./ -inum 167794 -exec rm \"{}\" \; rm: cannot…
mgjk
  • 874
  • 3
  • 9
  • 20
6
votes
3 answers

find files their name is smaller or greater than a given parameter

Say that in a given directory I got tzury@x200:~/Desktop/sandbox$ ls -l total 20 drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P000 drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P001 drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19…
Tzury Bar Yochay
  • 727
  • 11
  • 24
6
votes
2 answers

rsync only files created or modified after a date and time

The goal is to rsync (or using any other tools that give the desired result) only files that are created or modified after a date. It should work with filenames containing spaces (and/or other characters that needs to escaped). I succeeded using…
Yanik
  • 253
  • 1
  • 2
  • 6
5
votes
1 answer

Why is L2ARC not giving more speedup for directory traversal?

L2Arc is usually configured to cache random spinning platter reads on an SSD. I've set up this configuration in the hopes of speeding up directory traversal. This is the setup: # zpool list -v NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP…
5
votes
2 answers

What does rm {} + do?

As in find -L /etc/ssl/certs/ -type l -exec rm {} + So it finds all broken symlinks and deletes them. But how exactly do I interpret the {} + part?
yanchenko
  • 279
  • 1
  • 6
  • 13
5
votes
1 answer

How can i manipulate the find command to "find" the directories the "found" file is in?

So i'm trying to use the find command to find all files in my system with mtime -x. It does this but it does not "find" the directories of the file. find . -mtime -2 -exec rsync -av {} /destination/ \; I thought if i could bring over all the…
user768352
  • 53
  • 1
  • 1
  • 3
5
votes
3 answers

How do i use the {} operator in find execution inside exec

I tried this bash command: find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled But the second {} is not executed. It results in just ./index_disabled instead. How can I use the found parameter twice in the execute…
rubo77
  • 2,469
  • 4
  • 34
  • 66
5
votes
4 answers

How to do a for loop of filenames with spaces using find

I have the following script - its supposed to loop files names using find but it seams to break the files names up by a space? I need the file names to remain intact #!/bin/bash for file in `find -name "*.avi"` do ./myscript $file done Can anyone…
Rob
  • 215
  • 4
  • 10
5
votes
2 answers

Does "find" open files?

I recently issued this command: find . -type f | wc -l To count how many files are in my public_html folder. Shortly after, Nginx returned 500 internal server error and error.log was being flooded with "too many open files" error. I thought maybe…
Tar
  • 265
  • 4
  • 11