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
17
votes
3 answers

Get all extensions and their respective file count in a directory

Getting all extensions for a directory: easy. Getting file counts for a particular extension: easy. But getting all file extensions and their respective file counts is alluding me. eg. + dir + abc.txt + def.txt + abc.pdf * def.pov should return…
denormalizer
  • 491
  • 2
  • 5
  • 15
17
votes
8 answers

How do I find all files and directories writable by a specific user?

Under Linux, how can I find all the files and directories that are writable (or, actually, not writable) by a particular user? Edit: To clarify, I meant under a particular subdir, not systemwide. And yes, that means all the permutations and…
Pistos
  • 3,093
  • 6
  • 22
  • 21
16
votes
4 answers

How to use find command to delete files matching a pattern?

I'm trying to write a bash command that will delete all files matching a specific pattern - in this case, it's all of the old vmware log files that have built up. I've tried this command: find . -name vmware-*.log | xargs rm However, when I run the…
Dan Monego
  • 285
  • 1
  • 2
  • 7
16
votes
6 answers

How can I use netsh to find a rule using a pattern

I'm wondering whether anyone in Microsoft has ever come to a situation where they can't remember a rule's name! The netsh advfirewall firewall show rule only accepts 1 name and no pattern matching facility is available on netsh to help find a rule…
Achilles
  • 412
  • 2
  • 8
  • 17
15
votes
1 answer

How do I find circular symbolic links?

I'm working on a HP-UX system and I want to find if there are any circular symbolic links. So far I'm using the command: ls -lrt `find ./ -follow -type l` But it's only doing ls -lrt on current directory as result. What command should I use to…
Vladimir
  • 153
  • 1
  • 1
  • 4
15
votes
2 answers

find files NOT belonging to group

How do I find files not belonging to particular group? find /home -group NOT test
Michael
  • 397
  • 1
  • 7
  • 15
14
votes
1 answer

Linux find command is misbehaving

Searching for system-resolved service following the recent vulnerability disclosure, I came to see a very strange behavior from find command. root@localhost:/# find . -name…
user2808671
  • 183
  • 10
14
votes
3 answers

how to find files with incorrect permissions on unix?

I'm looking for a way to search a directory or directories and list all the files that have the wrong permissions for a public directory.
sal
  • 827
  • 3
  • 12
  • 18
14
votes
7 answers

How to Find a file in FreeBSD

I'm trying to locate all copies of example.filename on my FreeBSD server. What's the best / easiest / most efficient way to do this?
Ian
  • 1,498
  • 4
  • 26
  • 32
13
votes
9 answers

How do I master the UNIX find command?

I think I am fairly advanced in my use of find but EVERY time I use it I cannot for the life of me remember the method to close the -exec option. I spend a good deal of time reading every time I use it. Am I simply not using it enough or expecting…
ojblass
  • 646
  • 1
  • 9
  • 17
11
votes
3 answers

Unix magic, delete all .pyc files from a tree of directories?

Is there a quick way of deleting all the .pyc files from a tree of directories?
interstar
  • 1,281
  • 4
  • 18
  • 23
11
votes
5 answers

What is the correct find -exec syntax

I wanted to delete files that were greater than 2MB within a specific folder. So I ran: find . -size +2M And I got a list of two files ./a/b/c/file1 ./a/f/g/file2 So I then run: find . -size +2M -exec rm ; and I get the error message Find:…
Safado
  • 4,786
  • 7
  • 37
  • 54
11
votes
3 answers

finding a file which was modified in last 10 minutes

I am running this command to find out the files which were modified in last 10 minutes find / -fstype local -mtime -10m but it is giving following error each time find: missing argument to `-mtime' What is wrong with above?
Registered User
  • 1,463
  • 5
  • 18
  • 37
11
votes
4 answers

Why does FIND on Windows 7 give an "Access Denied" error?

I have an administrator account on a Windows 7 x64 machine. It is not THE administrator account, the account is simply a member of the administrators group. The install is default. When the user opens a command prompt it ends up in the users'…
rann
10
votes
3 answers

Securely use find with sudo

On a Linux server, I need to remove root privileges from a group of users. But those users have legitimate reasons to be able to use the "find" utility to search for files based on file names, modification dates, and other metadata. On the server,…
Troels Arvin
  • 652
  • 7
  • 17
1
2
3
20 21