Questions tagged [find]

A commandline utility to find files and directories.

A command-line program to find files and directories, filtered by a bunch of conditions, which can be further processed with multiple options, available on unixoid systems and, as a gnu-tool, for win32.

Ubuntu has a Community Wiki page that serves as a great introduction to the use of this admittedly complex utility:

Ubuntu Community Wiki - find

674 questions
331
votes
9 answers

Find a file by name using command-line

I would like to determine the location of a file using command-line. I have tried: find . -type f -name "postgis-2.0.0" and locate postgis-2.0.0 to no avail. What is the command to determine the file's directory, provided its name?
Sam007
  • 4,653
291
votes
10 answers

How to list all symbolic links in a directory

I have a symbolic link in my /var/www/ directory that links to WordPress. When I run the command ls -la from the /var/www/ directory the link to WordPress doesn't show up. Is there a way to list all of the symbolic links that are in a directory?
Isaac
  • 3,105
  • 3
  • 15
  • 13
210
votes
12 answers

How to exclude/ignore hidden files and directories in a wildcard-embedded "find" search?

Starting from (notice the wildcards before and after "some text") find . -type f -name '*some text*' how can one exclude/ignore all hidden files and directories? I've already been googling for far too long, came across some -prune and !…
208
votes
10 answers

Find number of files in folder and sub folders?

I want to find the total count of the number of files under a folder and all its sub folders.
topless
  • 7,465
133
votes
2 answers

Removing files older than 7 days

I write below command to delete all files that are older than 7 days, but it doesn't work: find /media/bkfolder/ -mtime +7 -name'*.gz' -exec rm {} \; How can I remove these files?
107
votes
10 answers

Get absolute path of files using 'find' command

Is there a way to get absolute path of a file that is being searched? For example: find .. -name "filename" It gives me results like ../filename but I want the full path. What I need is to find in the parent directory and its children, for a…
JorgeeFG
  • 2,098
95
votes
5 answers

Find directories that DON'T contain a file

Yes, I'm sorting out my music. I've got everything arranged beautifully in the following mantra: /Artist/Album/Track - Artist - Title.ext and if one exists, the cover sits in /Artist/Album/cover.(jpg|png). I want to scan through all the second-level…
Oli
  • 299,380
85
votes
4 answers

How to find a folder on my server with a certain name?

I have a directory somewhere on my server wth the name "exampledocs". I tried to find it's location using: ls -d */ | grep -E 'exampledocs' and find * -regextype posix-extended \-regex 'exampledocs' \-type d and grep "exampledocs" *…
user55596
77
votes
9 answers

How do you output the filename in find command while using -exec?

I use the following line to find all sub-directories of the PWD and run svnadmin verify on each directory (I already know that they're Subversion repositories) find ./* -maxdepth 0 -exec svnadmin verify {} \; This works well, other than the fact…
Arronical
  • 20,241
76
votes
2 answers

How to find location of installed library

Background: I'm trying to build my program but first I need to set up libraries in NetBeans. My project is using GLU and therefore I installed libglu-dev. I didn't note the location where the libraries were located and now I can't find them. I've…
Raven
  • 874
62
votes
7 answers

command to find files by searching only part of their names?

Say there are files with names: batman.c debate.c cricketbat.c What command and how should I use it to list all these files by using the searchtag bat?
srk_cb
  • 1,437
61
votes
10 answers

Filenames with spaces breaking for loop, find command

I have a script which searches all files in multiple subfolders and archives to tar. My script is for FILE in `find . -type f -name '*.*'` do if [[ ! -f archive.tar ]]; then tar -cpf archive.tar $FILE else tar -upf archive.tar $FILE…
Ubuntuser
  • 10,012
60
votes
2 answers

What does "{} \;" mean in the find command?

Sometimes I see the following command: find . -name  * -exec ls -a {} \; I was asked to execute this. What does {} \; mean here?
53
votes
6 answers

Find the latest file by modified date

If I want to find the latest file (mtime) in a (big) directory containing subdirectories, how would I do it? Lots of posts I've found suggest some variation of ls -lt | head (amusingly, many suggest ls -ltr | tail which is the same but less…
Rich
  • 563
52
votes
3 answers

How to find files between two dates using "find"?

I have an email account that has passed 60GB of emails, and currently I'm having a lot of trouble using an email client to archive emails of last year (2011). Via terminal, I am trying to use find to locate the files between 2011-01-01 and…
Zuul
  • 2,044
1
2 3
44 45