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

Find's -true option: what for?

GNU find (and others?) has a -true test along with the normal -name, -mode, -user and so on. From the man page: -true Always true. Every time I see the man page I notice this and wonder when it'd be useful. So, give me some examples of when it's…
markdrayton
  • 2,449
  • 1
  • 20
  • 24
9
votes
5 answers

How to find all filenames with given extension

I need to find all .pem files on my system. Would the following do this? sudo find / -type f -name *.pem If not, how would I write a find command to find every file of the sort?
David542
  • 939
  • 3
  • 10
  • 15
9
votes
2 answers

Linux & SVN: How to remove all versioned files but KEEP directory structure, ignore .svn dirs?

I want to remove all the versioned files from my repository, but KEEP the versioned directory structure. Obviously I want to leave all the .svn directories untouched. In other words, I want to completely empty a working copy's directory structure…
Brian Lacy
  • 1,113
  • 4
  • 15
  • 23
9
votes
4 answers

find only files in directory with permissions not set to 644 on linux

This is my first question although I've been lurking for a while. Question: I would like to use find to get only the files in a directory with permissions not set to 644 (or another permission value). Is there shorter way to write this or is the…
M Brown
  • 193
  • 1
  • 3
8
votes
1 answer

Find, and sort results by date created

How can I sort the results of find? I want to sort by date created asc? find /docs -type f | sort Sorts by filename not date created. Thanks.
Justin
  • 5,328
  • 19
  • 64
  • 84
8
votes
7 answers

Linux Colorize Find?

Is it possible to 'colorize' the output from find? I have a find that searches /home on all of my servers, and exec 'rm' certain files. As these are mixed in with my other find results, among other things, I'd like to colorize them. Is this…
JPerkSter
  • 285
  • 3
  • 12
8
votes
5 answers

How to remove directory on NFS fileystem with an enormous number of files

A poorly tested program created a directory on an NFS share with an enormous number of files, which I need to remove. ls -ald /home/foo drwxrwxr-x 2 503 503 317582336 Jul 29 11:38 /home/foo The directory is located on an NFS mount of about 600GB…
hrf
7
votes
2 answers

Why does this regex not work on linux?

I can't say it works on Windows but from my understanding this regex is correct and how I would write it (except maybe the ^ at the beginning) From…
user274
7
votes
1 answer

File is too big for /dev/null

While testing a problem LUN for read errors, I encountered the following problem: find /mnt/problem_lun/ -type f -print -exec dd if={} of=/dev/null bs=8k \; ... /mnt/problem_lun/a_file dd: writing `/dev/null': File too large 33619977+0 records…
Zogratz
  • 79
  • 1
7
votes
3 answers

Non-recursive find on linux

I am trying to find all directories that are directly inside the current directory and older than a specific age. The trick is, I only want to consider the age of the immediate descendants of the current directory, and not search through them…
SaltyNuts
  • 275
  • 1
  • 6
  • 12
7
votes
2 answers

List directories not containing a file

I've seen similar questions to this, but nothing I can find related directly to files. Is there any way to give me a list of directories which do not contain a specific…
Stefhen
  • 143
  • 2
  • 8
7
votes
4 answers

Bash: execute command on results of FIND

I am trying to resize all files that are found using a FIND command (they are all files within a directory and its subdirectories). I tried many options but stumble across different errors each time. This is my last attempt: find /my/folder/ -name…
user60129
7
votes
4 answers

Why does "find -mtime" not work as expected on files with different timezones?

I have some files on a server with the date several months ago, but they are invisible to find -mtime 7 search. When I list them with ls -l, they look perfectly normal: -rw-r--r-- 1 root root 347253 Jun 12 16:26…
Vladislav Rastrusny
  • 2,671
  • 12
  • 42
  • 56
7
votes
3 answers

Using `find` to delete

So, given three options... find .... -delete find .... | xargs rm ... find .... -exec rm ...; ..or variations thereof, which option is preferable? I'm guessing there is no hard and fast answer, and a specific situation will dictate the best…
Ben Davies
  • 73
  • 2
7
votes
4 answers

Locate, Find, Which - How do I launch an index/scan command for these utilities?

How do I re-scan my drive so my 'search utilities' are able to find a new file on my system? I'm having a tough time googling HOW TOs for launching an index/scan command to any of this applications. I mostly use: 'find' and 'locate', but thought it…
l0c0b0x
  • 11,867
  • 7
  • 47
  • 76
1 2
3
20 21