Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
2 answers
90 views

Find command slow when I'm not piping into awk

I have a script I've used for many years for building a list to some directories, with the following lines: ##Find all scenarios for this sector number find /gsgt/source/scenarios/AT_* -name ${...
atc_ceedee's user avatar
0 votes
1 answer
33 views

Script to find multiple files and update their timestamps by a second

I'm trying to create an interactive script that lets me choose a start date and time, then recurse into the present directory/subdirectories, find all flac audio files, sorted by directory/...
arcturus's user avatar
-4 votes
1 answer
88 views

Find actual file by only file name, not literally everything non-related

PuTTY/SSH and logged in as root I simply want to find any instances of the file PEAR.php. I've looked through a dozen different tutorials but they seem to just copy-paste the same instructions. An ...
John's user avatar
  • 194
2 votes
2 answers
212 views

find with du -sch and very many files

I have large folder structure and need to get the size of a certain subset. The directories I need to count are defined by having specific subdirectories: find . \( -iname a -or ... \) -printf "\&...
cheersmate's user avatar
1 vote
1 answer
48 views

find all zip files and hash the contents of the zip

I have a bunch of zip files in several directories, there are other non-zip files in these directories also. I am wanting to find all the zip files in the directories such as with find /mnt/sata2 -...
AeroMaxx's user avatar
  • 199
0 votes
1 answer
21 views

Output to multiple files when redirecting output during each find -execdir loop

I want to output a single .txt file for a bunch of mp4 or mkv files containing the mediainfo details for each video file. I am using find and then -execdir to create the mediainfo output, but for all ...
Justin Orton's user avatar
2 votes
1 answer
98 views

removing hidden control characters in filenames

I have a huge number of files spread across a large directory structure that have hidden control characters in their names. ls lists them as, e.g.: '614.7-4-F1-00-090-007-RozvadØ'$'\302\237'' RP1-...
atapaka's user avatar
  • 621
8 votes
1 answer
441 views

find -printf for file creation time is not working as expected, is it a bug?

I'm trying to print file date of birth ( crtime ), I'm working with ext4 and support for crtime enable: stat a File: a Size: 0 Blocks: 0 IO Block: 4096 regular empty file ...
Kiwy's user avatar
  • 9,764
0 votes
1 answer
44 views

how to pipe output of find into eog

I'm trying to view photos in a slideshow which are nested within other folders but can be found with the find command. The find command on its own does find all the listed photos but this - find /...
cardamom's user avatar
  • 602
1 vote
1 answer
49 views

How to find file names with non-printable characters using BSD `find -regex`?

Some folders on macOS have custom icons that are stored in a file named Icon?, where the ? is actually a CR character, and only prints as "?" in most cases (in Terminal and Finder). But when ...
Thomas Tempelmann's user avatar
0 votes
0 answers
70 views

Running find on NFS mount much slower on RHEL8 vs RHEl7

I'm in the process of replacing some RHEL7 NFS server/client systems with RHEL8 systems, performing the same functions. On the RHEL8 NFS client, I noticed running a find command on the NFS mount, is ...
keyboard_banger's user avatar
6 votes
2 answers
579 views

macOS find with "-f path" doesn't work?

man find: -f path: Add path to the list of paths that will be recursed into. This is useful when path begins with a character that would otherwise be interpreted as an expression, namely “!” , “(” ...
jsx97's user avatar
  • 71
0 votes
1 answer
30 views

How to set back file ownership from a reference (/etc) directory to a copy on Linux?

Context : Debian 12 system recovery trial after a btrfs file system corruption (roots tree) with no backup but access to all(?) the files. I made a copy of the system after the corruption, everything ...
lalebarde's user avatar
  • 265
0 votes
2 answers
40 views

Delete certain files from specific date in linux [duplicate]

I need a command how I can delete files from a folder with specific date. Like I want to delete files before 20 April from a folder on /home/FTP and file types are mp4.
White hat Mahmud's user avatar
2 votes
3 answers
283 views

How can I use find paired with grep to delete files

I am attempting to write a script to delete files from a directory. find /home/docs/* -name "*.log" -type f -print -exec rm -f {} \; The above works however I need to use grep to target ...
newdeveloper's user avatar
0 votes
1 answer
80 views

Why does find ....-execdir rename miss files? zsh

I'm using zsh on MX Linux 23.2. For years I have tried to figure out why a command like find . -depth -type f -execdir rename 's/_720p//' {} \; skips over files. I know my file manager can't be ...
Terry 's user avatar
  • 35
0 votes
3 answers
163 views

What are the file size options for "find . -size" command?

I found out that to look for file size in bytes, I use 'c'. So I can look for file size with 1000 bytes by using: find . -size 1000c But what about different kind of size such as Mb, Gb or even bits? ...
Mardia's user avatar
  • 119
2 votes
1 answer
67 views

Continue a directory tree checksum from a given file

I have: A checksum.txt file which contains many lines of checksums of single files from a mountpoint in a huge directory, which mounted and then it disconnected, thereby not finishing the checksum....
Sir Muffington's user avatar
8 votes
5 answers
2k views

How to execute a command on all files whose names match a pattern and whose contents match a pattern?

Say I want execute cmd on all *.cpp and *.hpp files that contain the word FOO. As far as just finding those files goes, I know I can do, find /path/to/dir -name '*.[hc]pp' -exec grep -l 'FOO' {} + ...
Enlico's user avatar
  • 1,677
0 votes
2 answers
67 views

How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression?

For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all ...
Anton Samokat's user avatar
1 vote
1 answer
28 views

Moving and organizing files with find

I have a folder on a Debian GNU/Linux 12 (bookworm) x86_64 Server used as a NAS/Homelab server with a lot of files from a surveillance camera. MDAlarm_20240301-091804.jpg ... MDAlarm_20240316-153813....
JoSSte's user avatar
  • 195
0 votes
1 answer
44 views

Using find with regular expression

I try to understand how to use the find command with regular expressions (macOS 14.4.1, Zsh 5.9). I have a directory with files such as note-red.png, note-yellow.png, (and other colors), folder-red....
jsx97's user avatar
  • 71
3 votes
6 answers
208 views

Find files that are sorted before a given file

I have a directory with a number of files. Example: aaa.txt bbb.txt ccc.txt ddd.txt Given an arbitrary string (not necessarily the name of one of the files), I want to find all the files that are ...
Lii's user avatar
  • 175
0 votes
1 answer
79 views

How to exclude multiple directories from chown -R?

I am writing a bash alias to fix permissions that keep getting messed up on my Synology NAS while running Docker. I just need to chown & chmod everything in the /volume1/docker directory except ...
DasKraut's user avatar
0 votes
1 answer
75 views

Find - xargs, for every line open a new shell and execute a command and wait for user to exit that shell

Following works Task: List all folders that contain file of iname *AlbumArt* that also contain iname *cover*.jpg, and for each of those folder list all jpg files with size find . -type f -iname '*...
Porcupine's user avatar
  • 2,056
0 votes
1 answer
57 views

value of $VAR already contains backtick and/or single quote inside. How to handle it? How to properly pass $VAR to program? [duplicate]

$ bash --version GNU bash, versione 5.2.26(1)-release (x86_64-pc-linux-gnu) I don't know how to deal with $VAR when its value inside contains single quote (') and/or backtick (`). I'm in the need of ...
dAllARA's user avatar
  • 33
-1 votes
1 answer
58 views

Find all the -perm -o=x ! -perm /o=rw folder, and all ancestor paths to this folder need x permission for "others"?

I found that sudo -u <user> test might work, but I don't have the sudo command on my system. For example /a d......--x /a/aa d......--x YES /b d......--- /b/bb d......--x NO When I use the root ...
hrdom's user avatar
  • 1
2 votes
2 answers
63 views

Listing a certain part of filenames and their contents

I have a Linux machine with BusyBox, which has a directory called /data/var/lib/connman.  That directory holds some directories that I'm not interested in.  But it contains many .config files that ...
Norbert's user avatar
  • 121
2 votes
1 answer
409 views

Is there any way to get `find` not to quote the result of -printf

I want to use the find command with -printf '%h\0' to print the leading directories, separated by the nul character. Since I am using \0, I don't need, and don't want find to quote the results, as ...
Thayne's user avatar
  • 235
2 votes
2 answers
109 views

Search and replace composed Unicode characters

I have a deep folder structure on a Debian machine where the directory names and the filenames contain some "special" characters (ä,ö,ü).  However, these are not in "ISO-8859-1" ...
rockZ's user avatar
  • 769
3 votes
1 answer
76 views

Why does reading a file with hexdump sometimes change find's sparseness value (%S)?

I use a Lustre file system. I've noticed that if I look at the find's sparseness value (%S) for a file, then print the file with hexdump, then look at the find's sparseness value again, then ...
Franck Dernoncourt's user avatar
0 votes
2 answers
49 views

linux find and rename items with backslash not working as expected

I have tried a couple of approaches to find and rename some files that hold a backslash (mind you these files generated from a web app do not have the quoets) in a directory. I've tried with find and ...
gstlouis's user avatar
2 votes
1 answer
147 views

MacOS find: illegal option -- n

To preface, I'm very new to using the Mac terminal and SRA Toolkit. I used the following command to download sra files from NCBI using SRA Toolkit prefetch -O output_directory --option-file ...
Lucy Kelly's user avatar
0 votes
1 answer
51 views

Find all the folders that are concealed using 'chflags'

I have concealed some folders on my laptop using chflags: chflags hidden hide-me And I don't remember where exaclty these folders are located. How is it possible to find all of them? (Probably by ...
jsx97's user avatar
  • 71
0 votes
1 answer
29 views

How to test availability of primaries of the "find" command and output which ones it supports?

I am writing a script that determines whether find supports the following primaries: iregex Btime atime inum with +/- So far, I came up with this: find / -mindepth 0 -maxdepth 1 -inum +0 -exec echo &...
Thomas Tempelmann's user avatar
4 votes
2 answers
496 views

Untar files from a huge tarball, but only created between two timestamps

I would like to untar only that files created between 2024-02-19 01:00:00 and 2024-02-19 02:00:00 from a huge tarball. I don't know how should I combine the tar and the find commands, because I can't ...
tazvagyok's user avatar
1 vote
2 answers
47 views

Which -newerXY option finds all files that are accessed after creating or modifying another file?

This question relates to Xubuntu 22.04 if that matters. Probably it is a general Unix question, however. In a shell script, I first want to create a reference file, e.g. by echo $(date) > ~/...
Adalbert Hanßen's user avatar
0 votes
1 answer
56 views

find with execdir, pipe redirection evaluated too early (quote issue?)

I use multiple GitHub accounts at work, so I need to modify the remote url to add my work account. I have figured out the recursive find -execdir, and how to get/sed/set the remote url, but I cannot ...
Robert Altman's user avatar
-1 votes
1 answer
58 views

How to delete all "stuff" (dir and files) older than x days?

I am aware of find -mtime +x -delete, but how do I use it - or use it in a script - in order to delete all the "old stuff" (including hidden files) ? Eg, if I have a dir target_dir: delete ...
Antonello's user avatar
  • 1,043
1 vote
0 answers
24 views

find subdirectories from different mount points without symlinks that have the same name as the subdirectory [duplicate]

I struggle to find a working find command, I hope someone has an idea. Imagine the following structure, where path and path{0..1} exist and they are each mounted from a network storage device: dir: /...
Oliver R.'s user avatar
  • 141
1 vote
1 answer
80 views

Add files from "bash find" to 7z archive

I did quite a bit of searching before asking this! (Even so I'm expecting to have a duplicate pointed out). So I collect a bunch of files, e.g.: find . -name "2020-*" ... is there some way ...
mike rodent's user avatar
  • 1,142
0 votes
1 answer
161 views

List all files in a directory, recursively, sorted by modification date

The main answer of Sort the files in the directory recursively based on last modified date gives a method to list all files in a directory, recursively, sorted by modification date: find -printf "...
Basj's user avatar
  • 2,559
0 votes
1 answer
47 views

find -prune: why does -print0 affect search results? [duplicate]

Scenario: $ tree . . ├── x1.txt ├── x2.txt └── x3.txt 0 directories, 3 files $ find . -name "x1.txt" -prune -o -name "*.txt" ./x1.txt ./x2.txt ./x3.txt $ find . -name "x1....
pmor's user avatar
  • 619
0 votes
1 answer
28 views

ffmpeg inside while loop with find unintentionally alters iteration variable

Can someone please explain to me what is happening here? This is what I have reduced my situation down to: # make 20 test gifs out of the same source file. for i in {1..20}; do cp -p ../some-random-...
WoodrowShigeru's user avatar
4 votes
2 answers
579 views

Is it possible to run find command from a bash script where the multiple name filters comes from a file?

I'm trying to have some tracking on a folder and wanted to use the find -name filters from a file. So I've prepared a file called filter_files that contains the filter, for example: cat filter_files: -...
avij's user avatar
  • 43
0 votes
3 answers
178 views

Build find command from arguments

I often need to find a file, but I'm not sure what the name is, something like this: $ find -iname '*foo*' -o -iname '*bar*' -o -iname '*blah*' This is a little tedious. I'd like to create an alias ...
Big McLargeHuge's user avatar
1 vote
1 answer
64 views

Bash: Legitimate folder paths not recognized

I tried using sed to convert PATH paths as an input to find: User.Name@Machine-Name ~ $ echo $PATH | sed -e 's/:/\n/g' \ | sed -n -e 's=.*="&"=' -e '2,5p' "/bin" "...
user2153235's user avatar
0 votes
1 answer
47 views

Find files with certain string in specific directories and replace

I have a folder structure like so. . └── apps/ ├── bo/ │ └── platform/ │ └── values-dev.yaml ├── canary/ │ └── platform/ │ └── values-canary-dev.yaml ├── ...
user avatar
14 votes
6 answers
2k views

How to recursively list all files whose entire content is exactly "\n"

I have some failed experiment result files, and their contents are exactly a single \n (newline). I would like to list them all (perhaps with something like find or grep), to know what are the files ...
FxMySz's user avatar
  • 144
1 vote
4 answers
613 views

Bash script - check if any files changed recently

I am writing a script which needs to check if any of the files in a given directory have been modified recently. I thought I could simply use find, however it reports success even if it doesn't find a ...
symcbean's user avatar
  • 5,839

1
2 3 4 5
71