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

learn more… | top users | synonyms

3
votes
1answer
323 views

I want to list all the files in my Linux server which are older than Dec 31, 2014

I want to list all the Linux files in a directory and sub directories which are older than 31 Dec 2014. Please help me out for this.
1
vote
1answer
45 views

find: missing argument to « -ok » [closed]

A while ago, I ran chmod to change some file permissions to 777. A friend of mine told me to never chmod 777, so I decided to change the permissions again. So, first I looked for all the 777 files: ...
1
vote
1answer
55 views

find command match issue [duplicate]

I'm having some trouble while searching files with find command and the way it handles the search. Let's say I'm currently in the directory /tmp and the directory contains the files: ...
1
vote
3answers
93 views

How to find empty directories in unix [duplicate]

I want to show all the empty directories under my home directory, using shell script, can you help me find the code? (without using find's -empty)
4
votes
1answer
323 views

Why GNU find -execdir command behave differently than BSD find?

On my OSX, I've installed GNU find next to default BSD find via: brew install findutils. As far as I understand, BSD find is following POSIX standards and GNU makes it optional (as per this post), ...
3
votes
1answer
317 views

Odd alias “find . -name '*\!{*}*' -ls” in Unix Power Tools

From Unix Power Tools 3rd Edition page 175: Article 9.27 shows a way to match directories in the middle of a path. Here's a simpler "find file" alias that can come in very handy: alias ff ...
3
votes
5answers
270 views

How to process special characters in in file name using find

I am to find all files that start with certail char , e.g find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print but what if someone create file that has special characters in the name of that ...
1
vote
2answers
21 views

Find doesn't work with recursion?

I ran the command below and notice it will only did the mod on the first level(SubDir*) on the finding and not the subsequence (ChildSubDir*). I wanted to ask if it is possible to go recursion on the ...
0
votes
1answer
142 views

shell find -delete “directory not empty” [duplicate]

i try to delete backupfiles on my synology nas older than 30 days, the files are in a directory which is created durig downoad the backupfile from my webserver after download i want to check -mtime ...
3
votes
1answer
104 views

Finding empty directories recursively

How can I find every empty directory, let's say, on the /home/.../Desktop. Because I am on Solaris, I can't use the find . -empty -type d command. Is there any other way?
5
votes
2answers
1k views

Find files containing string in file name and different string within file?

I would like to (recursively) find all files with "ABC" in their file name, which also contain "XYZ" in the file. I tried: find . -name "*ABC*" | grep -R 'XYZ' but its not giving the correct ...
3
votes
4answers
61 views

Finding mount points with the find command?

Is there a way to recursively search a tree for mount points on Linux? I'm looking to do something like this: find /tree -type mountpoint | sort -r | xargs umount
1
vote
2answers
91 views

use find and grep to find lines that contain some string and don't contain other string from files

First, I try the following code find . -name "*.cfg" | xargs grep "good"|grep -v "^\#" In the current folder, I get the list with the file name's extension is "cfg". Then I want to search the ...
2
votes
1answer
42 views

Is there a version of the 'find' command that saves its state?

If a find is searching a large disc, and is aborted for some reason, I'd like to be able to start it again, from where it left off. Is there a version of 'find' that does this? The problem is that, ...
0
votes
2answers
66 views

Bad Substitution when Renaming Files using find

I am trying to recursively rename image files using the find command. Currently, the command is written as follows: $ find . -name '*.jpg' -exec rename "${echo $(uuidgen) | cut -c1-8}.jpg" '{}' \; ...
3
votes
2answers
105 views

Find Files not an regex whitelist

I have a huge Folder with thousands of Files. Some Files have some Characters in it, which are not allowed. (UTF-8 signs) So I have a white list of allowed characters and a beginning of a bash-script ...
0
votes
1answer
76 views

Find files and recursively append text to them

I have been looking for an answer to this problem for a while: how can I use find append text to all hits? My original method was something like sudo find / -type f -name "*.py" -exec cat somecode.txt ...
2
votes
3answers
243 views

Can I use the find command to pass arguments to perl?

I have a perl script $ cat ~/script.pl sub main { my ($file) = @_; <STUFF> } } foreach (@ARGV) { main($_); } I want to execute ~/script.pl on every .txt file under the ...
0
votes
1answer
107 views

Find regex for timestamp in filename not working

I want find mail files in user maildir, without mailfilter, dovecot-index etc. All mail files have unix timestamp in its filenames, I think it is the easiest way. I used this regex: .*\/\d{10}\..*. ...
1
vote
1answer
87 views

How to recursively remove all but list of files?

How can I recursively remove everything in a directory EXCEPT a small list of files to preserve? For example, let's try to remove all files except ones named f2 and f5. # Create a testing ground ...
1
vote
2answers
40 views

path of folder within a folder in terminal

I have a number of files that are saved as Year -> Month -> Day -> bunch of .nc files I would like to generate a list of all of the directories that contain the nc files. I can list the ...
1
vote
1answer
57 views

Create file for every result of find command?

With this line of code I generate an output of every result. exec("find ics/ -mmin +3 -type f -name '*.pdx' -exec basename {} ';' > ./tmp/filename") How can I generate a file with dynamic file ...
1
vote
1answer
44 views

Zip subdirectories based on find, -exec

Here's what I would like to achieve: I have some directories, and subdirectories in them (which may have sub-subdirectories). In each subdirectory I want a zip file with contents of that particular ...
2
votes
1answer
67 views

Find and replace using parts of the found string in the replace string

Let foo be any string. I have to search a file for all occurrences of \LeftLabel{foo} and replace each occurrence with \LeftLabel{\textsf{foo}} but only if foo does not start with a $ ...
2
votes
1answer
41 views

who to get a count of “base subDir” without there subDirs?

All I am trying to do is get a count of direcrories on one leve of a tree. so Far I have this. find /media/data/temp1 -type d -exec basename {} \; which gives me this: temp1 Coldplay Greatest ...
1
vote
5answers
172 views

List (or move) only files with a certain number of lines?

Dealing with a whole bunch of two-line config files, I'd like a way to exclude any files that have a different number of lines. So, something like: mv * destdir only if file contains exactly two ...
0
votes
2answers
28 views

how to find the file size for softlinked files

I have a log of files that's on a NFS, and they are connected via softlinks on the local redhat server. When I try to run search for any files that was touched during last weekend and calculate ...
1
vote
1answer
835 views

Using regex quantifier with find [duplicate]

I've got a set of files in a directory, all of the format test[0-9][0-9].txt. If I run find . -regex ".*/(test)[0-9][0-9]\.txt" then all the files are shown, but if I run find . -regex ...
0
votes
1answer
31 views

Struggling with find

I have the following scenario: My directory-tree looks like this: /export/home1/user1/profile.V2 /export/home1/user2/profile.V2 my find command should find all profile.V2 directories: find ...
1
vote
1answer
46 views

How do I combine '-size` and '-exec rm' in find?

When I use this, it works: find /home -name "error_log" -exec rm -rf {} \; But when I try to add a file size limit, it won't remove any files: find /home -size +5000000b -name "error_log" -exec rm ...
0
votes
1answer
252 views

How to add subject line when sending email output of find using ssmtp

I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line. find /path/to/folder/ -type f -size +1M -name ...
1
vote
1answer
105 views

How do you assign {} to a variable in find --exec

I'm going to ask and answer this as I couldn't find the answer anywhere. I was trying to write a script that looped through each xml file in a directory and run make NAME= where NM was the filename ...
1
vote
1answer
43 views

copying and working on OSX .app files (folders) in linux

tldr; I want to run a script over an external hard drive and tar.gz every folder that ends with .app into their own archive. That is, I don't want them all in one tar.gz file, I want to create one ...
2
votes
5answers
196 views

How can I list the names of directories that contain files matching a regex?

Given a directory X that contains several subdirectories and files, I would like to list the names of the immediate child directories of X that (directly or indirectly) contain files matching the ...
0
votes
1answer
47 views

quoting problem when piping find output into xargs [duplicate]

I have a directory with the following subdirectories, i.e. If I run $ tree -L 1 . ├── 2007-06-20_to_2008-10-01 ├── 2008-07-21_to_2008_08_12-Nokia 2mp ├── 2009-11-01_to_2011-01-10 - All iphone Pics ...
1
vote
2answers
184 views

How does 'find -exec' pass file names with spaces?

If I have a directory containing some files whose names have spaces, e.g. $ ls -1 dir1 file 1 file 2 file 3 I can successfully copy all of them to another directory like this: $ find dir1 ...
2
votes
1answer
134 views

How to copy recursively all files not older than 1 day?

How to copy recursively all files not older than 1 day? I first tried find . -amin -1440 | xargs cp /dest But it doesn't work because the items given to xargs should be positionned before the ...
2
votes
3answers
245 views

How to iterate through files and delete those older than x days but NOT in use

So, I've been able to figure out bits of this myself but am having trouble piecing them together. I have a task I need to automate - I have folders filled with gigabytes of obsolete files, and I want ...
3
votes
5answers
447 views

Search files for a string and if found check if a file with paired name exists in the same directory

I have many different files with the same ending .ft1 that may or may not contain one specific word special. For the files that contain this word, I want to check whether another file with a different ...
0
votes
1answer
79 views

Cron to find exec cp and redirect output with time / date per line?

I try to setup a cron task to run a set of basic shell commands. I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date ...
0
votes
2answers
40 views

Only print filepath,without filename [duplicate]

The find command find /MOS -name "001.txt" The print /MOS/XNF/N01/001.txt My questions Which option could only print the filepath,without the filename ? The print /MOS/XNF/N01/
1
vote
2answers
36 views

Rsync two “filepath” found by find commands [closed]

Original file /001day/backup/001m/name_test_v1.txt Destination file /001date/003m/name_test_v12.txt Method 1 rsync -av --progress /001day/backup/001m/ /001date/003m/ Method 2 ...
0
votes
1answer
20 views

Cleaning script with find and anacron

I want to automatically delete old files in ~/Downloads. with exception of ones that have '!' in their name. My current version is as follows: find /home/user/Downloads/ -mtime +90 ! -path '*!*' ...
1
vote
2answers
96 views

Find works fine in command line, but won't work in script

I am trying to write a script on a Debian Jessie host. I am having an issue with trying to run the following command (with a twist) in a script: find ~/* -path ~/FileSniper* \ -prune -o \ -type f \( ...
1
vote
1answer
35 views

Search for file in folder1 and execute a script if that file isn't in folder2

folder1 contains only .flv files. folder2 contains only .mp4 files. All .flv files in folder1 SHOULD have a corresponding file ending in .mp4 in folder2 : /folder1/123.flv and /folder2/123.mp4. I ...
3
votes
3answers
72 views

Filter a list of files based on file attributes

With find you can search by file attributes like -type, -executable etc. How to achieve something similar, but from an existing list of files? e.g. the output of dpkg -L <package_name>. A pipe ...
3
votes
2answers
82 views

Why `find` likes `stat` or `fstat` so much?

I'm trying to make /usr/bin/find to show something meaningful without doing any sort of stat, with no useful results so far. If I forcefully inhibit stat, find stops descending into subdirectories at ...
2
votes
1answer
41 views

How to reuse file pattern in .gitignore in bash/zsh?

Here is the content of the .gitignore cron.yaml build target webview *.pyc *.sublime-workspace .idea *.rej .coverage app/tools/temp_*.py app/tools/*/temp_*.py I am currently iteraring files in a ...
0
votes
1answer
45 views

Delete Empty Folders - recursive [duplicate]

I would like to clean up some folders. So I want to delete all folders which are empty or only contain other folders... First I tried find . -type d -delete but this lists the subfolders after ...
1
vote
1answer
31 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...