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

learn more… | top users | synonyms

0
votes
2answers
252 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
195 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
806 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
526 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
2k 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
171 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
906 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
524 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
151 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
157 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
95 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
505 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
301 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
191 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 ...
1
vote
1answer
53 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
700 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 ...
4
votes
1answer
224 views

What is the '+' in find command for? [duplicate]

I have some times come across the use of trailing + while using unix commands like find. Example from SO post - find -exec touch -t 201007162310.00 \+ Please help me understand the use of this.
2
votes
3answers
449 views

How to use arguments with 'find -exec'? [duplicate]

I'm trying to generate static html files for all php scripts inside dir: find . -name "*.php" -exec php {} > {}.html \; But it just dumps all results to {}.html. How to do it properly? And how ...
1
vote
2answers
155 views

How can find support large files?

I would like to find all the files of my system, which sizes are more than a couple gigabits. I thought I would use find -size, but the man page states: The size does not count indirect blocks ...
1
vote
1answer
347 views

How does one find and replace text with geany in all files in a directory?

I see this discussion: How does one find and replace text in all open files with geany? I want to find and replace all files in a directory. The method suggested in the answer, is very good to find. ...
4
votes
3answers
1k views

The find command: the options '-mindepth' conflicts with the action '-prune'

If the file structure is like this: /a/p/c/d... /c/a/c/g/f/... /a/c/d/e/... ... And I want to do this: find -mindepth 3 -type d -name p -prune -or -name c -print However, this command will not ...
2
votes
1answer
291 views

How to keep track of which files are currently growing in directory

I have a local filesystem which is exported rw with nfs (very big xfs partition). Somewhere (I cannot determine who or what remote process) files are being written, created new or updated appending ...
5
votes
2answers
2k views

Excluding a specific directory using a recursive 'ls'

I've been using the following command to list the most recently updated files (recursively) within a specific directory and order by modification time: $ stat --printf="%y %n\n" $(ls -tr $(find * ...
0
votes
3answers
370 views

using find, exec, sed to manipulate strings as args to another program

I can use find like this find -type f -path "./src*" -name "*.php" to find a list of files. For example ./src/Superuseradmin/Model/Mapper/UUID.php What I need to do is manipulate each string in the ...
2
votes
2answers
258 views

Unable to concatenate files with find ./subdir/* -print0 | sort | xargs -0 cat > merge.txt

I am trying to concatenate thousands of files that result from processing the pieces output by split with find ./subdir/* -print0 | sort | xargs -0 cat > full_merge.txt The files under subdir ...
4
votes
2answers
518 views

Sort files by modification time

I've seen many questions and answers here using a construction along the lines of list_dir=`ls -t /path/to/dir/` for i in $list_dir; do or ls -t | while read i; do Now, I know that you shouldn't ...
3
votes
1answer
84 views

find utility does not recognize bracket notation

I've two files in the current folder: submitWeb.m submit.m the following find does not show the two files: find . -regex .*submit\(Web\)?\.m But the above regex expression works fine in ...
3
votes
3answers
7k views

List all files in a directory recursively but exclude directories themselves

Simple question, I'm running the following find command: find . -type d \( -path ./.git -o -path ./log -o -path ./public -o -path ./tmp \) -prune -o -print To list all the files in my directory, ...
1
vote
3answers
75 views

Variable scope in multiple pipes

I was trying to do something following, find . -name "*.dat" | get the basename of file | move filename returned by first command to basename returned by second command To give a concrete example, ...
2
votes
4answers
120 views

find command: how to ignore pathname?

I have to find some type of files in a directory and it's subdirectories and I only have to print out the filenames. So here's the main command: find -type f -name "*.c" Now, how could I cut the ...
3
votes
3answers
701 views

Concatenating thousands of files: > vs >>

I found two seemingly contradictory answers on StackOverflow to the following questions: Concatenating Thousands of Text Files Across Hundreds of Directories (while keeping some structure) How do I ...
1
vote
3answers
977 views

Setting file permissions in bash script

This script is not working the way I thought it would .I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5 #!/bin/bash # the / makes find ...
2
votes
2answers
771 views

How to find files with a certain subpath?

I need to find all xml-files that are placed in folders named config. Also config must be somewhere under a folder named trunk. For example, I am interested in all files like below: ...
1
vote
3answers
78 views

Apply two commands to result of find

I am trying to apply two command (echo and haml --check) to result of my find. haml --check `find . -name "*.haml"` # return Syntax error on line 2: Illegal nesting: nesting within plain text is ...
0
votes
1answer
5k views

How do I redirect output from the find command (that uses grep) to a log file?

Consider the code to search for all files containing the pattern "search string": bash-3.2$ # The below find works fine.. bash-3.2$ find . -type f -exec grep -il "search string" {} \; bash-3.2$ # But ...
2
votes
2answers
1k views

Exclude all subdirectories except one specific path in a find command

I use a find command to search for all files with a given extension within the current subdirectories ignoring certain directory path: find -L . \( -wholename "*/ignoredPath" -o -wholename ...
3
votes
5answers
4k views

Find and copy directories containing file type

I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc. I'm trying to copy all directories containing ...
11
votes
1answer
398 views

How to do `head` and `tail` on null-delimited input in bash?

find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
1
vote
2answers
102 views

Why don't find and locate search /bin?

What gives? Normal find and locate commands don't turn up the verify program that lives at /bin/verify. In fact, it seems they don't turn up anything that lives in /bin [jake@jace]/bin% "find" /bin/ ...
6
votes
1answer
170 views

find is missing a result — how is that possible?

What conditions explain this output: root@ip:/# find / -name "server.xml" -print /etc/tomcat7/server.xml root@ip:/# ls /var/lib/tomcat7/conf/server.xml /var/lib/tomcat7/conf/server.xml I am ...
2
votes
3answers
2k views

Passing multiple directories to the -prune option in find

I am using find to locate and delete backup files but wish to exclude certain directories from the search. The backup filenames could terminate in .bck, bak, ~, or backup. The Minimal Working Example ...
1
vote
1answer
130 views

chmod allowing write when I am not setting it

I've got a perl script which systematically changes permissions. The first thing the script does is remove all permissions. It does this by calling chmod(from perl). I did this as I found the set guid ...