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
5
votes
4 answers

Find directories that do not contain a directory?

I'm trying to figure out how to use the linux "find" command (or another command that will get the job done) to return a list of file paths/directories that do not contain a directory of a certain…
erikcw
  • 697
  • 14
  • 22
4
votes
2 answers

Command find show "Value too large for defined data type"

When I run the "find" command in any folder, works perfect, but only in a particular folder I get this: root#find . find:.: Value too large for defined data type It is a shared folder from another server nfs. With umount and mount not change…
juan
  • 41
  • 1
  • 1
  • 3
4
votes
4 answers

find command with parameters in variable

> find /etc -name 'shells' /etc/shells # good !! > SEARCH="-name 'shells'"; find /etc $SEARCH # nothing found - bad !! Why "find" command can't take params in variable? Other commands work fine in such mode. It is probably related with spaces…
xoid
  • 143
  • 1
  • 6
4
votes
1 answer

Look on all server desktops for outstanding files before deleting profiles

We have about 70 servers that we are in the process of moving into a domain environment, so we are converting our users from local accounts to domain controlled accounts. How can we determine which users may have files on their desktop or documents…
jcolebrand
  • 298
  • 5
  • 27
4
votes
1 answer

Glob Not Match?

How to list files that don't match a glob? E.g., let's say I have a directory that contains hundreds of files, 97% of which have the filename extension .png. I know I can list the PNG files with: ls *.png But, how do I list the opposite, i.e., just…
ma11hew28
  • 799
  • 2
  • 9
  • 17
4
votes
2 answers

how to list files that are NOT open using find command

I want to "list" all the files that are NOT open, within a certain directory using the GNU find command. Now, I am able to list the files that are open, but can't figure out a way to do the inverse of it. find /my/dir/* -exec lsof {} \; Any…
puffadder
  • 143
  • 1
  • 4
4
votes
2 answers

find all directories having less than x files inside

Assume starting at some directory in the filesystem. This base directory has lots of subdirectories (not nested!). Each of the subdirectories has an arbitrary number of files withing. How can I find all directories having e.g. less than 3 files…
4
votes
1 answer

How to search in centos or linux

I have found that sometime i can find files using locate but sometimes it dont find. Which directories it find the file using locate or find Suppose i want to find the files or directories having word denyhosts. Whats the best way to find that
John
4
votes
1 answer

Linux command to find all *.rb files

I still can't figure out how to use the Linux find command. I'm trying to find all the .rb files under the /var/www directory. What's the correct command to type in Bash?
John
  • 7,343
  • 23
  • 63
  • 87
4
votes
1 answer

Find only top directories matching search

I'm trying to find all the web folders that are 777. But I only want a list of the top folders. So if there is an img dir that has folders in it that are also 777 I don't want them returned. Basically I'm looking for a way to have find stop…
Slashterix
  • 612
  • 1
  • 5
  • 19
3
votes
2 answers

How to add the filename as prefix to each line of the text file? (batch processing; subdirectories)

I have many .txt files with their filenames being different dates: 01.01.2010.txt 02.01.2010.txt ... Currently each file (e.g.: 01.01.2010.txt) looks like this: 0.351 XXX XXX XXX XXX 0.292 XXX XXX XXX XXX How do I add the filename…
user3200534
  • 392
  • 1
  • 3
  • 10
3
votes
2 answers

Can I reduce CPU usage on a large recursive find + chmod command?

I'm using the following command to perform permissions fixes: sudo find . -type f -exec chmod 470 {} \; There are many thousands of files to update the permissions on. It also spikes the CPU usage during the run. A subsequent call that further…
3
votes
1 answer

Copy list of files (-I flag) with gsutil preserving path

I am trying to copy all pictures and static files to a bucket of mine in Google Cloud Platform. I am attempting this command from the root dir of my app: find -regextype posix-extended -iregex ".*\.(js|css|png|jpg|gif|ttf|cur|woff|eot)" | gsutil -m…
santiago arizti
  • 435
  • 6
  • 16
3
votes
1 answer

Find files and tar.gz the resulting list

Executing the following command works as expected: find /path/to/logs/ \( -type f -name '*20161005.log' \) -print0 | tar -czvf /path/to/backups/backup_logs_20161005.tar.gz --null -T - But, trying to use this within a bash script, I get an empty…
Zuul
  • 263
  • 1
  • 2
  • 9
3
votes
1 answer

Linux Find File with Exact Size

In the Linux command line, how can I find all files exactly 158 kB in size? I was using the following command but it didn't work: find /var/www/ -xdev -type f -size 158k
GTS Joe
  • 199
  • 2
  • 10