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

learn more… | top users | synonyms

2
votes
2answers
117 views

Filtering the result of the find command, so that it returns only directories

Is it possible to get only the results from find that are directory paths? Using find with some option, or using grep or some other utility the results are piped into as a filter? I thought something ...
0
votes
1answer
85 views

Problem with small bash script

I often run find in my code projects when I make a change somewhere and I have to find where it impacts other pieces of code, so I thought about writing a very small script to make this easier, call ...
5
votes
1answer
582 views

find -exec mv stops after first exec

While researching for this question: Find and move directories based on file type and date, I stumbled upon a problem of my own. First I created a bunch of directories with files in them: seq 10 | ...
3
votes
2answers
177 views

Exclude paths that make find complain about permissions

I need to generate a file list from a disk volume. Some of the directories (all hidden directories under the root directory) have strange permissions that causes find to complain. I try to exclude ...
1
vote
2answers
1k views

Find and move directories based on file type and date

I have a directory "New Movies" containing 200+ subdirectories "Movie Name (year)". The subdirectories "Movie Name (year)" contains a single video file (avi/mkv) and several related jpg/xml files. I ...
1
vote
2answers
719 views

Delete all files except certain subfolder [duplicate]

I want to recursively delete all files not accessed in a while in folder a, except all files in the subfolder b. find a \( -name b -prune \) -o -type f -delete However, I get an error message: ...
3
votes
1answer
1k views

find and rysnc?

I want to be able to search for files over 14 days and over 10k and than rsync those found files to a destination. Is there a way to combine these two commands? find ./ -mtime +14 -size +10k rsync ...
3
votes
1answer
274 views

Why does this one-liner clobber files?

I have written this to help me batch-encode some videos: find -name '*.mkv' -exec HandBrakeCLI -Z "Android Tablet" \ -c "1-3" -m -O --x264-tune film -E copy --decomb -s 1 -i {} \ -o `echo {} | tr ...
0
votes
2answers
214 views

The difference that quotation marks make in find command [duplicate]

When I have a nested directory find . -name "*.py" -print command gives me all the python scripts beneath current directory. However, find . -name *.py -print returns only the python scrips in current ...
1
vote
1answer
504 views

find and exec: why does this command not work?

I don't get why echo prints empty line (latest cygwin version): ~/tmp >find mydor/ -name "*php" mydor/es/c/packags.php mydor/etns/inx.php mydor/pacepors.php mydor/XAE.php ~/tmp >find mydor/ ...
6
votes
3answers
282 views

find all end subdirectories in a tree

given the following structure: oz123@debian:~/ $ tree . . ├── a │ ├── a1 │ ├── a2 │ └── a3 ├── a1 │ ├── a11 │ ├── a12 │ └── a31 ├── b │ └── b1 │ ├── b11 │ │ └── b21 │ ...
2
votes
2answers
2k views

Get list of all files by mask in terminal

I want to find all *.h,*.cpp files in folders with defined mask, like */trunk/src*. So, I can find separately *.h and *.cpp files: find . -path "*/trunk/src/*.h" find . -path "*/trunk/src/*.cpp" ...
3
votes
1answer
199 views

Variable declaration in parallel sh -c …

I've been trying to process the output of find with parallel, which in turn invoked a shell (some textual substitutions were needed). I observed some strange behaviour, which I cannot really explain ...
3
votes
3answers
14k views

How to find multiple strings in files? [duplicate]

I use the following command to find files with a given string: find /var/www/http -type f | xargs grep -iR "STRING1" But how can I find files which include "STRING1" OR "STRING2" OR "STRING3"? ...
3
votes
3answers
655 views

How to find file/directory names that are the same, but with different capitalization/case?

How can I list the file/directory names in a directory recursively that are the same, but with different capitalization/case? ex.: INPUT (not the ls command, the directories): [user@localhost ...
-1
votes
2answers
85 views

What's wrong with this tar command? [closed]

find /informatica/dev/SrcFiles* -mtime +7 -and -size +1M -exec tar -rvf files.8.2.2013.tar {} \; This command is running/working correctly and I'm not sure whats wrong. I want to find the files that ...
0
votes
2answers
122 views

find command and tar

find /informatica/dev/SrcFiles* -mtime +7 -and -size +1M -exec tar -cvjf> So I ran this command and I can't find the file after it was done running (probably because I never named it?). The ...
4
votes
3answers
1k views

How to find first match in multiple files

Is there a way for the find command to search for the first match or occurrence of a string or pattern within each of multiple files? I've been using the usual syntax: find dir -iname '*.ext' -exec ...
1
vote
2answers
106 views

find command help

I'm struggling using the find command that will allow me to find all files that were modified over 7 days ago and that are larger than 1 MB. Here's what I have - find /path/to/files* -mtime +7 | ...
5
votes
1answer
6k views

delete files matching pattern

I need to recursively remove all files in all subdirs where the filename contains a number followed by an 'x' followed by a number, at least two times. Example: I'd want to remove these files: ...
2
votes
3answers
200 views

mv files to a different path which is constructed via a regex replacement

I have a directory full of files stored in subdirectories according to their filename, i.e.: 20d1/d325/52d1/20d1d32552d1a95249e62662fbdf924dd72c4027.jpg ...
2
votes
1answer
105 views

find doesn't return expected files

I'm doing a search for files that contain ".anki" in their file name. root@t500:/home/some1# find / -name .anki /home/some1/.anki But there are other files in my home folder that contain .anki: ...
1
vote
0answers
24 views

find -exec {} vs. find -exec '{}' [duplicate]

I noticed in the man pages for find, that the {} always have single quotes around them. find -exec '{}' \; The description states: Notice that the braces are enclosed in single quote ...
2
votes
3answers
308 views

Find pattern and move

I'm wondering if anybody knows how to find a pattern and then move it to a different location. For example, I have many files named: odbc.ini_20110630 odbc.ini_20110639 odbc.ini_20110643 etc... I ...
3
votes
4answers
260 views

linux shell: find -exec in find -exec

I want to execute chmod 555 on all files and directories I get with the following command (it returns the directory test and all files and directories in it): find ~/.config/google-chrome -type d ...
2
votes
4answers
2k views

Change filename from lowercase to uppercase recursively

I have 1,000,000 files in some folders and subfolders. I want to rename them from lowercase to uppercase using shell commands. I don't want to modify the extension. only filename part. I have found ...
0
votes
2answers
262 views

Keeps on getting message files are identical using find

Whenever I enter this: find . -type f -name 'diag*' -mtime +30 -exec mv {} temp_diag \; in SunOS I always get this message mv: ./temp_diag/diagnostic.log.68.gz and temp_diag/diagnostic.log.68.gz ...
0
votes
2answers
203 views

find -print always prints the starting directory

I am trying to count how many files and folders I have recursively under a directory with 500K files with find (note: recursively and under). I am using the following command: find my_folder -name ...
4
votes
2answers
881 views

How to I scan using find for all files that do have execute bit set?

I want to write a permission fix script that uses find to fix permissions on files. Mainly what I need is a find command that is able to list all files with execute bit set, regardless of the other ...
4
votes
1answer
4k views

Moving files with find + xargs: target is not a directory?

When I run the following command: > mkdir some_dir > find /foo/bar/ -name '*.csv' -print0 | xargs -0 mv {} some_dir I get hundreds of lines that say: mv: target `/foo/bar/XX.csv` is not a ...
2
votes
1answer
59 views

List of Recently Modified Files of a specified user in whole disk?

One of my colleague is suddenly getting sick seriously and I need to finish his part, so knowing what he is working on most recently would be useful... For example, if I want to see the most recent ...
0
votes
1answer
549 views

Find and remove sub-directories without error?

I need to find a way to remove sub-directories from within a particular directory without receiving an error if no sub-directories exist. This command will successfully remove sub-directories if they ...
1
vote
2answers
2k views

Cheapest way to find the oldest file (recursively) from a directory under heavy load

What is the least expensive way to find the oldest file in a directory, including all directories underneath. Assume directory is backed by SAN and under heavy load. There is concern that "ls" could ...
1
vote
3answers
3k views

Count number of lines with a certain value in a column for all files in directory recursively

I have 40 files in a directory and I want to count the number of times there is a line with a "2" in the first column in each file individually. I am trying something like this, but it prints out ...
2
votes
2answers
2k views

How can I filter those “Permission denied” from find output? [duplicate]

I started using sed recently. One handy way I use it is to ignore unimportant lines of a log file: tail -f example.com-access.log | sed '/127.0.0.1/d;/ELB-/d;/408 0 "-" "-"/d;' But when I try to ...
0
votes
2answers
198 views

`find -path` explained

The find command provides the option -path. I understand that one has to define where to start looking [commonly known as "path"]. Trying to figure out what it is used for, I found many examples using ...
0
votes
3answers
988 views

How do I use find when the filename contains spaces?

I want to pipe file names to other programs, but they all choke when the names contain spaces. Let's say I have a file called. foo bar How can I get find to return the correct name? Obviously I ...
0
votes
1answer
540 views

How does -exec actually work

I am confused on the -exec command. E.g. in this case: find . -type f -name "*.c" -exec cat {} \;>all_c_files.txt It seems that I get cat file1 file2 file3 ... fileN While in this case: ...
0
votes
2answers
155 views

Why are there empty lines in the output of my command?: find ~/x/y/ | shuf > ~/Desktop/z.txt

As it turns out the reason for this problem was one filename with several newlines. (No idea how that happened.) find ~/x/y/ | shuf > ~/Desktop/z.txt This command works pretty much as expected ...
4
votes
4answers
166 views

How to deal with spaces in a variable

I'm working on some scripting: for x in `find ./ -name *.pdf` do echo pathname $x done My filenames are Test1 ( Volume II), Test2 ( Volume II). I'm getting a return of pathname Test1 pathname ( ...
0
votes
1answer
101 views

How to prevent find -execdir from following symlinks?

Say I have a symlink: linktob -> b If I run something like find . -type l -execdir chmod 777 {} \;, the chmod command affects the file the symlink is pointing to, i.e. ‘b’. The man page suggests ...
3
votes
1answer
543 views

How can I efficiently dereference all symlinks in `find` *output* filenames?

I need paths to be both fully resolved and relative to a given directory. This must be done efficiently, since the number of paths is often greater than 100,000. Situation: I have directories which ...
2
votes
2answers
315 views

dowload find binary , accidentally deleted /usr/bin/find binary file

I accidentally deleted all some binaries by rm -r f*, when my current directory was /usr/bin/ . So i couldn't install any files including findutils, since 'find' binary is the prerequisite for ...
5
votes
2answers
1k views

POSIX find all local files

I'm trying to write a cross-platform command line that will find all local files on a file system. My intention is to use the find command, using only POSIX parameters. Is there a way to skip ...
3
votes
4answers
193 views

Having some trouble using “find -exec {} +”

Disclaimer: I am a novice to Unix/Linux, but I am looking forward to learning! I have tried a search on this stackexchange and read the the man find, but I can't seem to figure this out. I want to ...
2
votes
2answers
3k views

How can I rename all files with one extension to a different extension recursively [duplicate]

Say I have a folder: / /a.bub /v.bub /dr.bub /catpictures /catpictures/or.bub /catpictures/on.bub How can I format a script to change each of these to .aaa. Here is what I've got, although it ...
2
votes
1answer
54 views

Change some ASP code to PHP code in all files

I'm migrating a directory of files containing fairly simple ASP code over to a PHP server and I need to modify the contents of all the files with a find and replace mechanism. I'm not great with ...
5
votes
2answers
739 views

Find/ls caching

It seems as though the first time I run find or ls on a directory, it takes a while to work. But, each time thereafter, it is fast, as though a list of the directory's contents has been cached or ...
2
votes
3answers
130 views

Why are POSIX Find Parameters Different from Other Program styles?

Why is a parameter in the POSIX find command added with a single hyphen for multi-character parameter names, while most other programs use single hyphen to indicate multiple single-character flags, ...
2
votes
1answer
1k views

find/rename command doesn't work

I am using Linux Slackware 14.0, bash 4.2. Suppose, I have 2 files in the directory: bash-4.2$ ls 1.txt 2.txt I want to rename them to .svg. This answer is accepted and upvoted, so I think, it ...