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

learn more… | top users | synonyms

7
votes
4answers
146 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
62 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
19k 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
44 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
42 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
51 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
40 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
48 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
35 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 ...
3
votes
5answers
292 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
58 views

Using Grep Command Without Specifying a Certain Directory [closed]

Can you use the grep command without specifying a directory path afterwards? Example: $ sudo grep "filename" / I have also tried this: sudo find / -type f grep -l "filename" Still no luck. ...
1
vote
2answers
49 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 ...
-1
votes
1answer
67 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
1answer
39 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 ?
0
votes
2answers
69 views

How to Do this List Comparison with Find?

I do and get a list of files where I would like to delete many duplicate backup files find . -type f -name '._*' I would like to find those files which have a corresponding filename /home/masi/....
0
votes
3answers
52 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....
-4
votes
1answer
27 views

Explanations of {} and -exec in the find command; of the -nr and +4 options to sort

Can some on explain the below command find . -type f -size +50000k -exec ls -l {} \; | grep -v "data/dr" | sort -nr +4 1) why { } is used ? 2) what is the purpose of using +4 is used after -nr? 3) ...
15
votes
3answers
11k views

Finding all “Non-Binary” files

Is it possible to use the find command to find all the "non-binary" files in a directory? Here's the problem I'm trying to solve. I've received an archive of files from a windows user. This archive ...
4
votes
3answers
309 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
50 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 ...
1
vote
1answer
161 views

How to Relink these symlinks after moving the system?

I moved my filesystem and symlinks from Ubuntu 14.04 to 16.04 by using FAT32 memory card, which apparently broke those links; stopped using BitTorrentSync. Differential condition is that those links ...
3
votes
2answers
31 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
3answers
3k views

Linux: Does find | xargs grep have limitations?

I've historically performed something like: find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null If my pwd is barfoo (/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. ...
1
vote
1answer
45 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
0answers
184 views

find returns 'No such file or directory'

Continuously getting so many warnings yet my command is working fine. find: `api/PlayersImpl0.smali': No such file or directory find: `api/PlayersImpl1.smali': No such file or directory find: `api/...
1
vote
1answer
36 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
34 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
54 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 -...
2
votes
2answers
60 views

Bash script to count file types in a path (including subfolders)

I would like to get a quick overview over the different file types in a directory (including all its subdirectories) using the file tool, e.g. telling me what file type is the most common one there. ...
33
votes
4answers
28k views

How to combine 2 -name conditions in find?

I would like to search for files that would not match 2 -name conditions. I can do it like so : find /media/d/ -type f -size +50M ! -name "*deb" ! -name "*vmdk" and this will yield proper result ...
1
vote
2answers
56 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 ...
3
votes
2answers
2k views

Understanding find(1)'s -exec option (curly braces & plus sign)

Using the following command, could someone please explain what exactly is the purpose for the ending curly braces ({}) and plus sign (+)? And how would the command operate differently if they were ...
0
votes
1answer
96 views

How to Solve this Read-only file system error?

I do find /media/masi/FAT32/ -type f -name '._*' -delete but I get find: cannot delete '/media/masi/FAT32/._booklet.pdf': Read-only file system I do not know how to work with such situations ...
22
votes
2answers
40k views

Why is my find not recursive?

I am running the following command, but it is not performed recursively: find . -name *.java I know there are java files further down in the current directory but it is performing the find on the ...
1
vote
0answers
27 views

Find recursively files that have a percentage of lines in common

Is possible to do this? I want an output where i have only files that are 50% the same of others or have 20+ lines in commons. I'm trying to isolate commons functions in *.java files. Thank you!
0
votes
1answer
35 views

Pass filename from find and execute command

I'm trying to write a script which finds certain files and executes a command with the files it finds. Doesn't sound too hard, but I'm having a lot of trouble getting it to work. Basically this is ...
2
votes
1answer
46 views

Permission denied when using -exec {} ls with find command

When run following command it gives me permission denied message for all the files. find /data/code/ -name "*.jar" -exec {} ls \; find: `/data/code/project/shared/build/thirdparty/log4j-1.2.8/...
1
vote
1answer
327 views

Copying wallpaper images into a single folder

In my ubuntu 12.04 set-up, there are lots of wallpaper images in the directory /usr/share/wallpapers. For example, one might be usr/share/wallpapers/Leafs_Labyrinth/contents/images/1600x1200.jpg ...
2
votes
1answer
65 views

substring removal in find -exec

When using $ find . -name string~ -exec cp {} FOO \; is there a way to use {} in FOO to remove the tilde character as we usually do with bash substrings e.g. : $ echo ${string%substring} I ...
0
votes
1answer
9 views

“find” doesn't list all files under specific directories

I'm attempting to get a list of all files under specific folders, recursively, with the "find" command. find / -path "/usr/sbin/*" -o -path "/usr/bin/*" -o -path "/usr/local/sbin/*"-o -path "/usr/...
1
vote
1answer
51 views

find X but exclude these?

Original find which works in OS X but not now in Ubuntu 16.04 find $HOME -type f -name "*.tex" -exec grep -l "masi" {} + | vim -R - (simplified version still; you can omit vim part but it just ...
26
votes
5answers
54k 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 ...
2
votes
2answers
153 views

find and remove files bigger than a specific size and type

I want to clean up my server from large log files and backups. I came up with this: find ./ -size +1M | xargs rm But I do not want to include mp3 and mp4. I just want to do this for log and ...
7
votes
2answers
2k views

How does this find command using “find … -exec sh -c '…' sh {} +” work?

@StephaneChazelas posted the following solution to this Q&A: Having some trouble using “find -exec {} +”. $ find . -iname "*.extension" -exec sh -c ' exec <command> "$@" <additional ...
2
votes
2answers
6k views

Command to find file/path lengths that are too long for burning to DVD?

I'm trying to burn a DVD from Windows but it fails because the full path name length exceeds the limit of something like 255 characters. Our files are stored in Debian Linux (accessed by Windows ...
0
votes
0answers
51 views

Does `find` return directories that are not on the file system?

I'm trying to identify where the python site-package matplotlib is installed on my computer. I ran find ./ -name matplotlib at the top most directory (called the root, no?) and was returned the ...
1
vote
1answer
37 views

Search files in a certain period and copy them into another directory

The problem is that I have a directory containing many files with extensions .xml, .txt and .p7m from year 2015 up today. I must create a script that searches into the directory 1 all files created ...
2
votes
2answers
65 views

how can I find files based on different names and delete all them in one single line [duplicate]

Finding files based on different names I know how to do. The problem is that I don't know how delete all of them at once. I am using OMVS in z/OS390. To find files searching by different extensions I ...
0
votes
1answer
27 views

Is there such a notion as broadening where find searches?

I'm trying to identify redundant installations of the site package matplotlib in my python3.5 environment. A contributor to the library (GitHub issue) is advising that I use python3.5 -m site ...