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

learn more… | top users | synonyms

3
votes
2answers
737 views

How to run "find -exec <script> {}\;

I have a script that changes the properties of the files for a folder. Here is the example tree: dir 1 --file 1 --file 2 --file 3 dir 2 --file 1 --file 2 dir 3 --file 1 ...
3
votes
6answers
881 views

Make directory copies using find

I have a directory with a bunch of subdirectories in it. Thus /usr/local/src/ccl/ccl-1.8/x86-headers$ ls elf gl gmp gnome2 gtk2 jni libc Each of these directories has a further subdirectory C ...
3
votes
2answers
705 views

Find files starting with ~$ (MicroSoft Word Temp files)

For some reason my machine is full of M$ Word temporary files such as: ~$Filename.docx ~$AnotherFile.docx Can someone suggest a find/regex command to search $HOME and delete them?
3
votes
4answers
5k views

Show files from the last 2 days on a mounted ntfs system?

What's exactly the command to show files younger than 2 days? I thought about something like this: $ find / -mtime -2 ...but I'm not sure how to print the date of the found files. My target is to ...
3
votes
3answers
367 views

How to grep recursive UNIX tree results along with each tree node?

Here is what I do tree -R /Applications/NetBeans/NetBeans\ 7.0.app/ | perl -e 'while (<>) { print if /java$/ }' but of course this doesn't return the result I want. What I want is to display ...
3
votes
1answer
86 views

-not -name does not work with find

I am trying to use find/grep to find some text patterns in my code base. I want to exclude non-source directories into which my build process duplicates source files: find . -name *.java -not -name ...
3
votes
1answer
287 views

find/grep outputs two lines for each file it finds match

I search my code base to find string patterns and list all the files where the pattern is found but only the file and not the lines on which it is found: find . -name *.java -exec grep -l 'someText' ...
3
votes
3answers
194 views

file mass deletion

I would like to delete all the txt, xls,pdf files in a directory as well as its sub directories. I would like to save everything else. find . -type f ! -iname '*.xml$,.png$,.jpeg$,.gif$,' -delete ...
3
votes
4answers
1k views

How to count recursively for the number of files in several directories?

I have a directory, containing a lot of files and directories. I am trying to get the number of files (and directories) contained recursively in every directory. I tried the following approach: for ...
3
votes
4answers
155 views

removing folders with find - strange message

mkdir foodir find . -iname foodir -exec rm -fr {} \; It does the job, but barfs message: find: `./foodir': No such file or directory
3
votes
2answers
186 views

Why does find -exec du sum up differently?

I have family pictures and movies in a folder /media/data/Selbstgemacht and I'd like to find the size of all pictures. In /media/data I use find Selbstgemacht -type f -iname '*.jpg' -exec du -ch '{}' ...
3
votes
2answers
580 views

Symlink all subdirectories in a directory to another directory

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
3
votes
2answers
92 views

How to find Emacs backup files?

Emacs backup files start with .# but I can find those in my directory. I've try: find . -name '^\.#.*' or find . -name '.*#.*' and they are not show up, and I have them. For instance if I create ...
3
votes
3answers
110 views

How do I search all subdirectories to find one with a certain name?

Let's say I have a top level directory called /dir and many sub directories. How do I search the subdirectories of /dir to find the one called x/x/dir/x/x/x/target? This question is similar to, but ...
3
votes
1answer
521 views

find multiple conditions with multiple execs

I'm trying to build a find command with multiple conditions that lead to multiple actions. It was suggested to me that I should use only one find command for efficiency. Here is what I have: ...
3
votes
2answers
118 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 ...
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 ...
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
1answer
381 views

Omitting extension with find?

I need to create thumbnails from multiple .png files and would like to do this using ImageMagicks convert utility. To recursively find all files that are not thumbnails themselves, I am using the ...
3
votes
3answers
3k views

Rename multiple directories

I want to find all directories with the last subdirectory named doc, for then rename them to Doc. How can be renamed? I've the first part: find -type d -name 'doc' which returns directories paths ...
3
votes
1answer
2k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
3
votes
1answer
85 views

How to ignore -ls errors in find

I'm writing a find command to look for files or folders with broken permissions (files should be rw, directories rwx) and trying to ls -l (give or take) the results. The following find command looks ...
3
votes
3answers
99 views

find 2 files with similar names and move them to a new location

I have a system with a watch folder where people/companies can upload new files via FTP or SMB. In this watch folder They should ALWAYS upload 2 files: 1 media file with a prefix name of ABC*.mxf and ...
3
votes
2answers
2k views

Get list of subdirectories which contain a file matching a string

How can I get a list of the subdirectories which contain a file matching a particular string? More specifically, I am looking for directories which contain a file with the letter 'f' somewhere ...
3
votes
2answers
948 views

Save find -exec output to text file

I have a set of videos in the folder. I would like to get the info about this videos using ffmpeg -i command and save the output to file. So I wrote the line: find . -type f -exec ffmpeg -i {} \; ...
3
votes
1answer
144 views

Find directories with a certain name

How can I loop through each directory recursively and whenever it finds a folder called VIDEO_TS, let Genisoimage convert that folder's content to an dvd-video iso image, the name of the iso would be ...
3
votes
3answers
367 views

Find directories without music files

My ~/Music/ directory is actually full of "empty" directories I want to clean. I say "empty" because this directories actually contain files, some contain old cover image files or Thumbs.db files. I ...
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
8k 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, ...
3
votes
2answers
9k views

Compress old log file into single zip-linux

I have a folder /home/testuser/log which contain log files of one day old *.log. I wish to compress all the log files older than one day to a single zip(gzip or tar.gz) and delete the older files. I ...
3
votes
2answers
1k views

How do I find a bunch of files with a string in its filename (or body text) and then move all those files to a specific folder?

Say - what if I wanted to move every HTML file in several independent directories with the word "heavengames" in its filename (and as a second question, every HTML files with the word "heavengames" in ...
3
votes
1answer
6k views

Difference between ctime 1 and ctime +1 in find command

If I run the following command: find . -name "*.jar" -type f -ctime +1 I get no results back, whereas if i run: find . -name "*.jar" -type f -ctime 1 I get results.
3
votes
1answer
297 views

Copy files in different subdirectories that excludes a string

I'm trying to copy all files of a type in a given directory and subdirectories but excluding files of a different type. find /var/ftp/pub/bs -iname "*foo*.foo" -exec cp {} /var/ftp/pub/bs1 \; ...
3
votes
2answers
953 views

Find files with same name but different extensions, send to tgz

I have a large archive of edited images from my camera, each image is actually a pair of files - *.nef & *.xmp. I would like to go through all the folders and then zip these pairs into single tgz ...
3
votes
1answer
3k views

Remove files, which provided by pipe

I have this command chain: find . -print | grep php | xargs grep 'eval' -sl | xargs wc -l | grep ' [1-2][0-9] ' This provide me this output: 14 ./includes/js/calendar/lang/vgju.php 18 ...
3
votes
1answer
57 views

List File Space Ownership By User

I have a 4TB NFS file system that is being served from a NetApp filer. The NetApp's quota tools tell me that a certain user is using X amount of disk space in that qtree, but it isn't in "their" ...
3
votes
2answers
440 views

Create Zip for each subfolder but containing only matched files

I am trying to figure out how to create a zip file for each subfolder containing only files that match my criteria. For instance I have: Folder1 Folder2 Folder3 Each folder contains the same set ...
3
votes
2answers
178 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 ...
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
3answers
657 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 ...
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 ...
3
votes
2answers
3k views

How to exclude NFS directories with find?

I need to search for files that has no user OR no group. find / -nouser -o -nogroup I think this is OK. But, I don't want to search NFS shares. How can I exclude the NFS shares in the find ...
3
votes
3answers
1k views

Find functions, commands, and builtins [duplicate]

Possible Duplicate: Executing user defined function in a find -exec call Suppose I have the following bash code: !#/bin/bash function print_echo (){ echo "This is print_echo Function" ...
3
votes
1answer
90 views

Find: Reference to Current Directory

I'm trying to use find with the regex option. However my regular expression only captures the basename of the file. Is there a reference to the "directory find is currently in" I can use in my regular ...
3
votes
2answers
603 views

List of top level folders with contents no younger than 30 days

I have an automated system for creating FTP accounts (vsftpd with jailed virtual users) that works well, but I still rely on manual cleanup of stale accounts. My definition of a stale account is one ...
3
votes
2answers
1k views

Script to find files with a specific extension but NOT containing specific text

I am trying to write a script that basically searches recursively using find (or another method to) to find all files ending with *.p or *.w but does not contain sysvars.i or preprocess.i I am new to ...
3
votes
2answers
3k views

How to find a writable file owned by root?

How can I find a file on my hard drive created by root that has write permissions?
3
votes
3answers
211 views

Use find to execute series of commands

I want to examine a directory and execute a command for each matching folder. The following find correctly returns the list I'm looking for. find . -maxdepth 1 -name "*.bitbucket" For each item ...
3
votes
1answer
36 views

How to find files/directories with specific ACL

How to I do something like find . -acl u:jim:rx find . -acl u:*:r find . -noacl u:jim:r etc. I know that the find command does not support this but, you have the idea. Are there any scripts, even ...
3
votes
1answer
82 views

Find the total disk usage not including files containing a string

I am trying to get the disk usage of the owncloud directory except not including the files and dirs containing the string nobackup in the name/dir. This is my command so far : find . -type f -not ...