Questions tagged [find]
For questions pertaining to find, a command-line utility to search for files in a directory hierarchy. Use this tag for questions about find itself or questions about issues arising from using the find command-line utility.
3,612 questions
0
votes
2
answers
65
views
What is /usr/sbin/authserver and the binary inside
When using the find command or any other recursive file searches, I always notice /usr/sbin/authserver in the context of a "permission denied" error. Just out of pure curiosity, what ...
7
votes
3
answers
510
views
How to separate start directories and expression in `find`?
find takes an (optional) list of (what the man page calls) "starting points", i.e. directories, followed by an expression. Is there a way to cleanly separate both types of arguments so that ...
0
votes
2
answers
109
views
find and regex matching behavior? Why won't 'L1[0-6].*' match "L15a" [closed]
I'm trying to understand some subtle behavior of find and its -regex option
I am trying to create symbolic links from files entitled slides_.*.pdf in folders that start with L1[0-6]. I tried the ...
1
vote
2
answers
135
views
find awk grep - search and replace & passing modified contents to awk to overwrite the existing file
I have a folder with many subfolders full of various Quarto(reg) files & in those files there are links that are located in varying positions in the file lines.
UPDATE ON 3 November 2025 in ...
6
votes
3
answers
377
views
Help w/ "posix-extended" regex for 'find'
Can someone explain the issue I've described below, and perhaps suggest a resolution?
I'm trying to process a set of filenames using find. My platform is macOS (Ventura 13.7.7), and the shell is zsh ...
4
votes
4
answers
462
views
How can I find common prefixes in file names to group them?
I would like to be able to find all files in multiple directories whose file names start with the same string, but preferably not if that string is only one word or contains fewer than perhaps 5 ...
1
vote
0
answers
58
views
What can go wrong with this command for flatten a directory recursively?
I have a very messy deep file hierarchy tree of files with duplicate names in different directories and possibly even duplicate files with different names.
$ find mp4/ -type f | more
mp4/._.DS_Store
...
0
votes
2
answers
103
views
Listing all the files and directories which have been moved in order on a drive
In my notes I had written:
To find most recently deleted files. Note: This will not search deleted files on external drives.
find ~/.local/share/Trash/files/ -type f -printf '%C+ %f\0' |
sort -rz | ...
11
votes
5
answers
1k
views
Using `find` to find a file in PATH
I would like to be able to search all my $PATH for files matching a given pattern.
For example, if my PATH is /usr/local/bin:/usr/bin:/bin and there's a /usr/local/bin/gcc-4 and a /usr/bin/gcc-12, I ...
6
votes
1
answer
402
views
About security concerns using in find -exec vs interactively performing the same task
My question is not aimed specifically at understanding find's and its -exec option's security implications, but more generally at understanding why (if at all!) such programs are particularly ...
-1
votes
3
answers
160
views
zgrep - Find an IP address in 1200 *.gz files
I want to find out in which of my 1200 *.gz files a certain IP address occurs on a certain date (17.07.2025).
I could not find the IP address in my current logs:
grep 'IP address' *.logs
My attempt ...
2
votes
3
answers
414
views
Create Subfolders for files and move them into, each for themselves
In Linux in a Folder there are these files:
LQ0gfKQej7GKG44Cn0sSAC.part01.rar
LQ0gfKQej7GKG44Cn0sSAC.part02.rar
LQ0gfKQej7GKG44Cn0sSAC.part03.rar
LQ0gfKQej7GKG44Cn0sSAC.part04.rar
...
0
votes
1
answer
85
views
Why does `find` have the tests `-anewer` and `-cnewer`, but not `-mnewer`?
(This is more a question out of curiosity and less a present problem that needs to be solved)
I recently learned more about time-related tests in GNU find, and something caught my eyes: With files, ...
6
votes
1
answer
730
views
How to find files by size that are not divisible by 4096 and round them up
In Linux in a Folder there are many files, all created with fallocate with random size.
How to find files whose size is not divisible by 4096 and correct the filesize (rounded up) to a multiple of ...
-4
votes
1
answer
129
views
How combination of find with sh solves problem with filenames
I was directed to this StackExchange post:
Why is looping over find's output bad practice?
The core issue is that Unix filenames can contain any character except the null byte (\0). This means there ...
2
votes
2
answers
129
views
find -not -name not working
Run command
find /volume1/Ingest -not -name '*.txt' -mtime +1 -print
and got the following output
/volume1/Ingest/test/Cube Emergency Lighting Locations Aug 2018.pdf
/volume1/Ingest/Cube Microplex ...
-1
votes
1
answer
98
views
list dependencies of all the shared libraries
I want to list the dependencies of all the shared libraries residing in a directory. I'm using ldd -r command to list the dependencies of a given shared library and redirect that output to a text file ...
0
votes
1
answer
65
views
find or ls -l recursive output in YYYY-MM-DD format on FreeBSD
I'm trying to list files recursively with this date format YYYY-MM-DD on a on FreeBSD.
I tried the Linux commands I know but none of them worked :
$ ls -lR --time-style=+'%Y-%m-%d %T'
ls: unrecognized ...
3
votes
1
answer
270
views
Help needed for command to avoid leading zero in month part
We are using command
find $$dirpath_err -maxdepth 1 -type f -name "*XYZJPQ*_"`date +%m_%d_%Y`"*standard_error.csv"
but the file is generated as ...
2
votes
0
answers
89
views
find output is different from ls - what could be the reason for this?
On a MacBook, I tried to access one of the system apps, Maps.app which is normally a folder stored in /System/Applications on a separate volume (here mounted as /System/Volumes/Data). What I found odd ...
2
votes
0
answers
127
views
Why is BusyBox find 10x slower than GNU find?
on a directory containing ~26 million files, GNU Find is 10 times faster than BusyBox find, why?
/var/www # time find /var/www -regex .*\.\(php\|js\|json\|html\|htm\|css\) -not -regex \(.*/docroot/...
0
votes
1
answer
104
views
How does `find` replace `{}` if it contains special characters like `"`?
Recently when I read one QA, it has some unexpected behaviors for me:
~/findtest % echo three > file\ with\ \"double\ quotes\"
~ % find findtest -type f -exec sh -c 'set -x;cat "{}&...
1
vote
1
answer
56
views
How can I show list of all unhidden files on my Mac Terminal using find command?
How can I show list of all unhidden files on my Mac Terminal using find command while using relative path for patent directory as param (i.e. ../../) ?
I tried,
find ../../ -path "*/.*" -...
4
votes
2
answers
461
views
Find items by name, and print out if they are files of directories?
Consider the following example:
mkdir /tmp/test2 && cd /tmp/test2
mkdir -p aa/{tmp,src}
mkdir -p bb/aa/{tmp,src}
mkdir -p {dd,ee}/bb
touch {dd,ee}/bb/aa
tree | awk '{print "# " $0}'
...
0
votes
1
answer
191
views
Combining grep with find command
I am trying to remove junk from rsyslog directories (mainly a lot of empty sub-directories or sub-directories with a single partial log file) but with all kinds of different names ranging from words ...
0
votes
2
answers
74
views
find script to sort subtree into most recent modification times?
What is the find script to sort a subtree into files with the most recent modification time? Also preserving their path name?
I suspect it has something to do with find, ls, awk and sort. I haven't ...
-1
votes
1
answer
85
views
Unix 'find' utility : Question about relation to Kleene Star in Mathematics
Does anyone know how the Unix find search -name queries with _? in leftmost column relate to Kleene Star as defined on Wikipedia? How can I accomplish the rows with _? using find?
. : empty ...
0
votes
2
answers
189
views
find command: how to find all such files with a mask?
I'm trying to filter out files using find, however am having difficulty. Does anyone know the correct command to filter out "Untitled.rtf" using file permissions? BSD like?
-rwxr-xr-x@ 1 X ...
0
votes
2
answers
107
views
Using find with vim for file that contains whitespace
I have a file which contains whitespace in its name: my file.txt.
If I want to find a file which has this name and pipe its output to a vim with args, I must use --null|-0 in order to handle ...
0
votes
1
answer
25
views
Different output for find between two SuseLinux servers
I have two Suse 15.6 servers, both have the same directories and files; the first example running on a GCP VM and the other on an VMWare VM.
Not sure which ENV var I'm missing, since both have declare ...
1
vote
6
answers
367
views
Move a lot of folders with spaces in the name
I have a lot of webpages saved in my Download folder and I want to move all html files together with its folder (for every "NAME.html" exists "NAME_files/" folder).
The big ...
2
votes
1
answer
91
views
Why does the order of -prune and -path change the output of find?
This question is answered on another stackexchange (stackoverflow) but I couldn't find it because I searched for the answer here. I'm posting my question here so the answer is easier for the next ...
0
votes
1
answer
77
views
Find + Sed + Grep command for checking replacements
Trying to test that my sed works by filtering through the files again with grep.
There may be hard but succinct ways but I'd prefer some idiomatic way to remember.
This fails:
find src -type f -name &...
0
votes
1
answer
125
views
Find and remove empty files: '-size 0' vs. '-empty'
To find and remove empty files, I have found the following Stack Overflow question:
https://stackoverflow.com/q/3157343
There are about 10 answers there, but all of them use -size 0 and not -empty.
E....
0
votes
0
answers
42
views
Is there a way to use linux "find" and filter if specific process was the only one accessed it? [duplicate]
I am trying to find out a way to do incremental antivirus scan. My current approach under evaluation is using "find". You can see relevant question here: Is there a reason why I can't ...
4
votes
3
answers
1k
views
Is there a reason why I can't use find to scan modified files for viruses and malware?
I need to scan Linux systems for viruses/malware, on the entire file system. There are few options to consider.
One is normally what users do: Use antivirus to scan system once a day.
The second ...
0
votes
2
answers
112
views
Adding up sizes of directories using bash is inconsistent
First, I got the total size of folder /my-downloads:
$ du -sh /my-downloads
304G /my-downloads
As you can see, it's 304G.
Then, I wanted to find out the total size of all immediate directories ...
2
votes
2
answers
238
views
Find with -mtime fails checking current day files
Consider the two commands below which are scheduled to run at the same time (Via Autosys, at exactly 8 AM).
The find command removed files older than 15 days but exited with non-zero status with:
???...
0
votes
1
answer
279
views
Performance of chown and chmod or find and running in background in parallel?
I have up to terabytes of data (a large number of smaller files) that could contain wrong owner, group or permissions. To repair that we had a script doing
sudo -n chown -R user:group "/path"...
2
votes
0
answers
102
views
find -regex for several extensions [closed]
I'm trying to cleanup some files on a Debian 11 machine.
These files live in a subdirectory in:
/tmp/.debrief, or
/opt/site/var/debrief
I can identify them by the extension in their filename:
....
2
votes
0
answers
60
views
In the context of {ARG_MAX}, how robust is `find . -exec sh -c 'exec tool "$@" extra-arg' find-sh {} +`?
Suppose I want to do this:
find . -exec tool {} extra-arg +
It doesn't work and I know why: -exec … {} + does not allow extra-arg(s) between {} and +. So be it. It seems I can inject the extra-arg by ...
3
votes
2
answers
155
views
Build find command from arguments in a POSIX compliant shell script
I'd like to know if it's possible to write a POSIX compliant script that builds a find command from its arguments.
The way to do it for Bash (and zsh) is explained in this other SE article but it's ...
0
votes
1
answer
102
views
To use `find` to find hidden files but ignore DS_Store ones
I try to use find to find files...
that are hidden using chflags, like chflags hidden my_file
or the filenames of which start with a period, like .my_file
and ignore macOS-specific .DS_Store files
...
1
vote
1
answer
123
views
Bash - Having trouble with the find command and excluding paths
Short background; I have a script I run to put new TV episodes into my library after conversion and naming. It just locates the matching directory by name. Recently I fsck'd my drives, and it warned ...
1
vote
1
answer
51
views
Solaris 10 find exclude directory 'oracle'
find . -type f -size +390625 -prune '/oracle' -exec ls -lh {} \;
find: bad option /oracle
Just want to find all large files on system but exclude /oracle.
Thanks in advance.
5
votes
1
answer
2k
views
'-depth 1' vs. `-mindepth 1 -maxdepth 1'
I have the following directory structure on a macOS machine:
dir1/
|- file1.txt
|- dir2/
|- file2.txt
|- dir3
|- file3.txt
I then run these two find commands:
find . -depth 1 -path '*.txt'...
0
votes
1
answer
95
views
String replace in wildcard using find command
I want to exclude all C files that have a matching asm file. The assembly files all have _x86_64.S at the end. The C files have identical names, but with .c instead of _x86_64.S at the end. How would ...
1
vote
2
answers
125
views
Using an environment variable to ensure that paths with certain names are never searched in find?
Is there an environment variable I can set to be read by find (WSL Ubuntu 20.XX LTS) so that it never searches paths that contain, for instance node_module or .git when find runs a search?
Or would ...
1
vote
1
answer
153
views
NetBSD "-f" option in find
I can't understand what "-f" option to find command on NetBSD mean.
Manual: https://man.netbsd.org/find.1 says
-f Specifies a file hierarchy for find to traverse. File hierarchies may ...
2
votes
1
answer
183
views
cp 'same file' error when using -L with find and xarg
I'm trying to replace symlinks in my current directory with the files they point to. I thought I understood 'cp' and the '-L' argument, but apparently not.
Here's the command I am using
find ./ -...