find is a command line utility to search for files in a directory hierarchy

learn more… | top users | synonyms

0
votes
1answer
38 views

Delete files older than X days - mtime, ctime and atime doesn't work

I'm running a script on synology (NAS) that is deleting files older than x days on certain folders. The problem is that I want these files to be deleted after X days of being uploaded on the folder. ...
1
vote
1answer
33 views

Optimize find -exec {} with multiple conditions : specific files in a dir and specific subdirectories in this dir

My problem is related to music encoding on my NAS and optimisation of linux find command. I have write a script that is totally functionnal but I am sure this not the best way. To summarize: 1/ It ...
30
votes
6answers
57k views

How to delete directories based on `find` output?

I issue the following command to find the .svn directories: find . -name ".svn" That gives me the following results: ./toto/.svn ./toto/titi/.svn ./toto/tata/.svn How could I process all these ...
1
vote
2answers
38 views

Using “find” non-recursively?

Using /bin/find /root -name '*.csv' returns: /root/small_devices.csv /root/locating/located_201606291341.csv /root/locating/located_201606301411.csv /root/locating/g_cache.csv /root/locating/...
1
vote
1answer
35 views

compress all pdf files recursively

i want to compress all my pdf files in an given directory and its sub-directories using ghostscript. I´m stuck using the find command within loops by filename including spaces. Here some example ...
4
votes
3answers
394 views

Recursively find all files named “file.txt” and execute a sed command

The challenge of my task is that the file.txt can be in subfolder or in sub-sub folders. The general structure looks like this: folder |___subfolder |_____file.txt | |...
2
votes
4answers
6k views

rsync timed out

I need to sync a directory to a directory on a remote server. at the moment i use rsync -ca to do this but the directory is quite large and the whole process fails with a timeout error. Now I'm ...
2
votes
3answers
35 views

How to get last folder (sorted alphabetically in descending order and matching a pattern) using ls/find/etc?

So I have these filesystem structure /my.parent -> my.folder1 -> my-file1.txt -> my.folder2 -> my-file2.txt -> another-folder-here -> another-file.txt Using ...
2
votes
2answers
89 views

Exclude from wildcard (*) using find

I have a command in bashscript that will find the files from a wildcard folder name and count it from that wildcard folder we have a test folder that I want to exclude from count. Here is my command ...
2
votes
4answers
66 views

Extract the directory path containing the file with matching string

I have multiple subdirectories at multiple levels containing a file results.out ./dir1/results.out ./dir2/dir21/results.out ./dir3/dir31/dir311/results.out Now i need to search for string1 in ...
11
votes
3answers
7k views

find with -execdir

When I run find with -execdir I don't get the results I was expecting. For example: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
1
vote
1answer
32 views

Rename multiple directories at once

I have a project with many directories named proj $ find . -iname proj ./include/proj ./src/proj ./lib/proj ./share/proj ./doc/proj I want to rename all these directories to test with -exec mv. I ...
6
votes
3answers
496 views

Grep word within a file then copy the file

I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific ...
11
votes
6answers
90k views

List the files containing a particular word in their text

I would like to list the files recursively and uniquely that contain the given word. Example: Checking for word 'check', I normal do is a grep $ grep check * -R But as there are many occurrence ...
-1
votes
4answers
41 views

Extract files from a directory and save the files' names and sizes in KB in a CSV file

I want to retrieve all the .log files from the directory /var/log, store the results in a csv file along with each log file's respective file size in kB. I started by getting the files using find: ...
1
vote
1answer
33 views

Clearing folders except specific type of files

I have tree of folders as follow: parent folder ....folder A ....folder B ....folder 1 ....folder 2 ....folder C ....folder 1 ....folder 2 ....folder D ....folder 1 ....folder ...
3
votes
2answers
46 views

Problem with spaces when used in find command

I'm trying to place a zip file with the content of the directory in each directory that doesn't contain any subdirectory. The following command works if there's no space in dirnames and/or filenames ...
0
votes
1answer
30 views

Why does GNU find suppress printing -prune'd directories when another “-or” test is applied? [duplicate]

I have a directory with the following files and a .git directory, e.g. . ├── .git │   ├── branches │   ├── COMMIT_EDITMSG │   ├── packed-refs │   └── refs ├── readme.md ├── server_build.sh └── tags ...
4
votes
3answers
499 views

What is meaning of {} + in find's -exec command?

I want to know the meaning of {} + in the exec command, and what is the difference between {} + and {} \;. To be exact, what is the difference between these two: find . -type f -exec chmod 775 {} + ...
0
votes
1answer
34 views

How to use `find -exec` to execute command in directory of found file (not current directory)?

Let's say I'm in a directory which has some subdirectories, dir1, dir2, and dir3. Each of these directories have a file foo and I would like to execute the same command on each foo in each of the ...
2
votes
1answer
59 views

how best to send the output of a find + exec command to a pipeline?

I would like to understand how to correctly send the output of a find + exec command to a pipeline for further processing. i.e. how can we (1) select a group files (2) perform some operation on the ...
4
votes
2answers
71 views

Is it possible to find files created between two specific times while ignoring the dates?

I have a time lapse of thousands of jpgs and would like to know if its possible to list only the shots taken during daylight hours? So it's not about listing the files between two dates, but listing ...
0
votes
2answers
53 views

Adding find contents to array

I've currently got a script that generates R commands based on the output of find #!/bin/bash PATHX="/path/to/my/files" find "${PATHX}" -maxdepth 1 -type f -name "*.csv" | while read d; do FN=$(echo -...
0
votes
1answer
26 views

Move files only if filename based regex does not match file in target dir

Best explained by an example: Source dir: file-a-1.txt file-b-1.txt Target dir: file-a-2.txt Expected result: file-a-2.txt file-b-1.txt Move all files from src dir to target dir only if ...
0
votes
0answers
31 views

Why is this curl command stalling when inside a while read loop?

This curl command, when used alone, is performing its job perfectly fine. But since curl does not support wildcard or pattern globbing, and that per shellcheck errors "find commands inside for loops ...
6
votes
6answers
3k views

Find images by size: find / file / awk

I've been trying to find png image files a certain height (over 500px). I know that file will return image dimensions. Example: $ file TestImg1a.png TestImg1a.png: PNG image data, 764 x 200, 4-...
2
votes
1answer
39 views

Search for files inside multiple subdirectories and zip directories [duplicate]

I need to extract more than 2k files from 1000 folders..the problem is, each folder has a zipped folder inside and inside this folder, there is another folder called "fileholder" which contains some ...
1
vote
4answers
68 views

How do I delete file by filename that are set as dates?

I want to delete file not by date access or created, but by filename. The filenames will be dates and I want to have a cronjob run once a week that will purge filename dates older than 7 days. I could ...
0
votes
1answer
31 views

How to Avoid Many Levels of symlinks with this find?

I know the thread and try to fix my find with -mindepth 15 unsuccessfully find -L $HOME -type f -name "*.tex" \ -exec fgrep -l "janne" /dev/null {} + | vim -R - Unsuccessful attempt find -L $...
30
votes
4answers
76k views

Recursive grep vs find / -type f -exec grep {} \; Which is more efficient/faster?

Which is more efficient for finding which files in an entire filesystem contain a string: recursive grep or find with grep in an exec statement? I assume find would be more efficient because you can ...
0
votes
1answer
54 views

Deleting duplicate file with exactly same filename but different sizes

folder_1 ./a20160606_000000_000021.txt 5KB ./a20160606_000000_000062.txt 5KB ./a20160606_000000_000531.txt 5KB ./a20160606_000000_004521.txt ...
1
vote
1answer
69 views

Why getting these “Permission Denied”s in POSIX find-grep readable?

I do in Posix find $HOME +perm 0666 -type f -exec grep -l "XSym" {} \; but get this which I do not understand find: ‘/home/masi/.dbus’: Permission denied grep: /home/masi/.viminfo: Permission denied ...
1
vote
3answers
110 views

Find Directory if Number of files is over X

Am wondering if someone can advise on the best way to do this. In my Web Dir is around 100 folders; each folder is a clientID. Within each ClientID folder is a Sub-Set of folders. In each subset ...
15
votes
3answers
4k views

How do I remove “permission denied” printout statements from the find program?

Code find / -name netcdf Output find: `/root/.dbus': Permission denied find: `/root/.gconf': Permission denied find: `/root/.gconfd': Permission denied find: `/root/.gnome': Permission denied ...
13
votes
7answers
20k views

How to report number of files in all subdirectories?

I need to inspect all sub-directories and report how many files (without further recursion) they contain: directoryName1 numberOfFiles directoryName2 numberOfFiles
2
votes
2answers
42 views

Properly set execute bit based on file type?

I'm trying to cleanup permissions on an Apache web server. I'm finding lots of files with the execute bit that don't customarily have it (or should not have it): $ sudo find /var/www/html -executable ...
3
votes
2answers
129 views

How can I know the total size taken by specific kind of files in my hard drive?

Like the title says I would like to know if there's a command that can tell me how much storage are the .jpg files (for example). Something like if I do find / -iname "*.jpg" which can add the size of ...
2
votes
3answers
41 views

Find a specific file in the nearest ancestor of the current working directory

I'd like to find a way to find a given file by looking upward in the directory structure, rather than recursively searching through child directories. There's a node module that appears to do ...
14
votes
5answers
633 views

Find files that contain multiple keywords anywhere in the file

I'm looking for a way to list all files in a directory that contain the full set of keywords I'm seeking, anywhere in the file. So, the keywords need not to appear on the same line. One way to do ...
2
votes
5answers
5k views

Bash rename 360 000 files using find -exec

I've got around 360 000 files like: ./001/1/1.jpg ./001/1/2.jpg ./001/2/1.jpg ./002/1/1.jpg ./003/1/1.jpg ... pattern: [60 dirs]/[1000 subdirs]/[4-10 files].jpg I want to rename files using rename ...
2
votes
2answers
89 views

How to Find All .tex Files in Directories in Recurse Grep?

I want to expand the recursive search of symlinks to include only .tex files find . -type l -name "Math*" -exec grep -d "recurse" word {} +. Failed pseudocode 1 find . -type l -name "Math*" \ -exec ...
0
votes
1answer
9 views

How to Limit ContentMatches of Grep in List? [duplicate]

I know the thread here which proposals (... | cut -c 80) however give single letter outputs like n r s t p. I do # http://unix.stackexchange.com/a/293147/16920 find -L $(find . -type l -name 'Math*')...
-1
votes
1answer
437 views

How to find the htpasswd file created for SVN over Apache?

I setup subversion with remote access over apache. I created an htpasswd file for it, but now I've forgotten the filename and path. How can I find it?
1
vote
1answer
71 views

Why is find not listing matching files when preceded by an asterisk(*)? [duplicate]

On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex ...
6
votes
3answers
20k views

How do I get absolute path from using find unix command

How to get absolute path by using find command. actually I am running the following script:- find . -size +20M | while read a do i=$(echo $a | sed 's:/: :g') echo $a; j=($i) ...
3
votes
2answers
52 views

Remove old files in a directory except files present in an exception file

I am writing a shell script to delete old files (older than 60 days) in a directory except few files and these file names are maintained in an exception file present in another directory. I know the ...
1
vote
2answers
49 views

Find files with pattern and get latest one

I want to find file with specific pattern and print the latest file matching the pattern with full path find ../*.gz -type f -print0 | sort -nr | cut -d: -f2- | head -n 1 How do I print the full ...
2
votes
2answers
69 views

Pass input file through pipe as argument?

I have two issues. I am trying to pass files through a pipe as an argument, and I am trying to use that file as a variable inside the sh function. Here is my command: find . -name 'segment*' | ...
1
vote
2answers
42 views

How does the -name switch to GNU find work when targeting a directory and its contents?

I have a folder full of source files for an application, the project uses git for version control and so there is a .git directory: ├── composer.json ├── .git │   ├── branches │   ├── config │   ├── ...
-1
votes
1answer
53 views

Recursively move files with different names and different extensions [duplicate]

How can I recursively find all audio and video files in a directory and move them elsewhere in a single operation?