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

learn more… | top users | synonyms

0
votes
1answer
29 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
30 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 ...
1
vote
2answers
37 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/...
4
votes
3answers
393 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 | |...
1
vote
1answer
34 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 ...
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
65 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 ...
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
495 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 ...
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 ...
-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: ...
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 ...
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
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 ...
4
votes
2answers
70 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 ...
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 ...
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
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 ...
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 ...
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 ...
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 $...
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 ...
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 ...
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*')...
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 ...
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 ...
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 ...
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 ...
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?
2
votes
1answer
53 views

How to use “cat” command on “find” command's output?

I want to redirect the output of the find command to cat command so I can print the data of the given file. So for example if the output of find is /aFile/readme then the cat should be interpreted ...
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*' | ...
4
votes
5answers
308 views

Add space between files paths

I have a list of folders and inside every folder I have the file " file.txt" which has the same name in all the folders. I wanted to collect the path for this file from all the folders and save it in ...
1
vote
2answers
50 views

Find a folder excluding one

I would like to find a folder not named "STDF", then archive them. find /a/b/c -mindepth 1 -maxdepth 1 ! -path "STDF" -exec /usr/bin/gzip '{}' \; The above command is not working. Can someone ...
4
votes
1answer
40 views

How does find evaluate expressions?

find man page says that -print action has a value of true, so why does this command find /home \( -not -print \) always list all files in directory ?
-1
votes
1answer
68 views

How to find a dynamic folders?

Hello StackExchangers, I created folder like this : $folder_name=`date "+%Y%m%d"` $mkdir -p ${DIR_LOG}/${folder_name} Example of folders name: [20160622], [20160621]...etc Now I need to find ...
4
votes
3answers
329 views

Using `find` on not existing directory

Is there a simple way to make this silently do nothing, if /my-directory does not exist? find /my-directory -type f -mtime +14 -print0 | xargs -r0 rm Versions: find: GNU findutils 4.5.10 bash 4.2....
1
vote
1answer
68 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 ...
0
votes
2answers
27 views

Search by pattern, and copy within the same folder but with a different name

This is the folder structure: /home/user/Pictures/Vacation/Italy/Rome/photo.front.001.jpg Within the folder Rome I have many other photos, but I'm only interested in the ones that have "front" in ...
3
votes
2answers
32 views

Forward results of Find command to javac

I wish to compile the results of a find command where the find command returns the relative filepath of a java file located in subdirectories. E.G., I am in ./ and I want to run javac on a file, ...
1
vote
1answer
59 views

How do I find and list folders with a specific folder name, containing files modified recently?

I have a set of folders that are regularly updated, which I would like to regularly parse through and update to a simple text file list. This list gets used with rsync so I shorten the file names ...
0
votes
3answers
79 views

Find-grep for List of .tex Files?

My document.tex where I want to get the list of files, and grep those files with the term gastric \subimport{}{1.2_protocal_answers.tex} \subimport{}{2_protocol_answers.tex} 1.2_protocal_answers....
1
vote
1answer
37 views

How to find files their names, name of files are in one file?

I know how to find and concatinate pdf file. I did with the follwoing code. pdfunite *.pdf output.pdf But the problem is I have list of file names in one file say filenames.txt and I would like to ...
0
votes
2answers
44 views

How to print lines using find and sed in multiple files?

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files. I've tried this : find . -path "*alder/ * / * .html" -print | xargs sed -...
-1
votes
2answers
56 views

delete files from specific folders using shell script

I am using Red Hat Enterprise Linux Server release 5.6 (Tikanga). I wrote one shell script to delete files from specific folders. find /app/psoft/pscfg/appserv/prcs/ABC/LOGS -type f -mtime +45 -...
1
vote
2answers
70 views

Bad substitution trying to rename extension [duplicate]

I'm trying to convert all wav and mp3 files to ogg files recursively with find and FFmpeg. I have made the following bash script to do so: #!/usr/bin/env bash # Converts samples to ogg find samples ...