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

learn more… | top users | synonyms

2
votes
3answers
331 views

Which is a better way to search- find with regex or find with grep?

Of these two ways of searching a file recursively in all the subdirectories, which is faster / better ? find . -regex ".*/.*abc.*" or find . | grep ".*abc.*"
1
vote
2answers
860 views

rsync: how to include files with name ending in a specific string [duplicate]

Possible Duplicate: Rsync filter: copying one pattern only I would like to use rsync to transfer all files from a server (or server-via-ssh) which have a specific ending string, such as a ...
2
votes
1answer
115 views

How to run a command against all the files of particular types on a filesystem?

I've just recovered tons of files (distributed in a complex directory structure, having very long names, using Unicode symbols, spaces etc in names) from a damaged hard drive. Now I'd like to verify ...
1
vote
3answers
458 views

Merging files into one also adding a new line between each file

I'm using find . -type f \( -name "*.js" ! -name "*-min*" \) -exec cat {} \; > all.js to merge files together. Unfortunately I don't get a new line after each file but it ends and the new file ...
10
votes
6answers
4k views

How do I list every file in a directory except those with specified extensions?

Suppose that I have a folder containing .txt, .pdf, and other files. I would like to list the "other" files (i.e., files not having the extensions .txt or .pdf). Do you have any advice on how to do ...
4
votes
1answer
3k views

Find and remove many files by specific content [duplicate]

Possible Duplicate: Arg list too long error while using find I try to find many files in many folders with specific content, and delete them. find dir.*/* -exec grep -l "content" {} \; | ...
9
votes
4answers
8k views

How can I use bash's if test and find commands together?

I have a directory with crash logs, and I'd like to use a conditional statement in a bash script based on a find command. The log files are stored in this format: /var/log/crashes/app-2012-08-28.log ...
0
votes
2answers
1k views

how to search case insensitively (with '*' wildcard) with 'find'?

The main problem is my directory has many files with uppercase (e.g. Foobar.txt, FooBar.txt, even FOOBAR.txt). And I find it messy to find the files by exactly typing it (if I know the exact ...
3
votes
2answers
3k views

how can I recursively delete empty directories in my home directory? [duplicate]

Possible Duplicate: How to remove all empty directories in a subtree? I create directories very often, scattered over my home directory, and I find it very hard to locate and delete them. ...
7
votes
2answers
2k 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 getting an archive of files from a windows user. This archive ...
3
votes
6answers
808 views

Get a list of directory names with find

I know I can do this to get a list of directory names: find . -type d -maxdepth 1 The output looks like this: . ./foo ./bar I prefer the listing without ./. Is there a way to get find to output ...
2
votes
2answers
585 views

Remove 50GB oldest files in busybox when used capacity reaches 95%

Ok i have requested a code here but initial i didn't ask to make it busybox compatible. My bad. I'm new to linux and coding. The code needs to do the following: Delete 50GB of oldest data (dir ...
2
votes
1answer
73 views

How to process directory first, then files and directories under it?

On my Linux system, I've got into a situation where there are not write/execute permissions on directories on a mounted drive. As a result, I can't get into a directory before I open its permissions ...
2
votes
1answer
133 views

How to have find only search for files in changed directories?

Currently I'm repeatedly doing a 'find' that's too slow. I'm searching for non-hidden executable files within "$root", excluding "$root/bin": find "$root" -type f -perm -o+x -not -path "$root/bin/*" ...
3
votes
5answers
371 views

Flatten Directory but Preserve Directory Names in New Filename

How can I flatten a directory in the following format? Before: ./aaa/bbb/ccc.png After: ./aaa-bbb-ccc.png
2
votes
2answers
119 views

How to generate folder ownership lists for each user?

I'd like to generate several separate lists for each user in Ubuntu. The lists contains the files and folders belong to each user. Using the command following list me all the users in the system: ...
3
votes
1answer
6k views

Find a file in lots of zip files (like find command for directories) [duplicate]

Possible Duplicate: Find recursively all archive files of diverse archive formats and search them for file name patterns I need to search for a file in all zip files in a directory. Is ...
1
vote
1answer
368 views

rename files maching specific mtime value within directory

I use simple set of shell commands to in order to create mysqldumps daily. The script is called by cron daemon. It looks like: presentdate="`date +%d-%m-%Y_%H:%M.%S`" basedir="/var/db_my_backup" ...
1
vote
1answer
3k views

What is the command to find a jar file in a particular folder?

What is the command to find a jar file in a particular folder? Say I want to find log4j.jar in the /dev directory, what command should I use?
6
votes
2answers
132 views

How can I substitute into this shell command?

I have a find command that I want to substitute a list of GIDs into. Here's the command: find / -follow \( -group 39 -o -acl_group 39 \) -exec ls -ln {} \; 2> $HOME/error.39.log 1> ...
2
votes
4answers
678 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 ...
4
votes
3answers
1k views

Use a shell variable to execute a comand

I have a unix command in a variable, it looks like this: cmd="find /path/to/webpage -type f | grep -v .svn | xargs grep $@" `$cmd` find: paths must precede expression Usage: find [-H] [-L] [-P] ...
4
votes
2answers
320 views

Find and regex

What am I doing wrong with this find expression? ; touch ook ooks ; find . -name 'ook' -or -name 'ooks' -type f ./ook ./ooks ; find . -name 'ook[s]?' -type f [returns nothing] ; echo $? 0
3
votes
3answers
1k 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 ...
5
votes
2answers
2k views

missing argument to find -exec

I want to remove certain files using find and -exec. But unlikely bash tells me, that I'm "missing" some argument. find . -name *.png -exec rm {} /; what do I miss? same "missing argument" return ...
8
votes
2answers
973 views

Use find command to convert markdown files to html

Lets suppose I have files on my harddisk having extensions as .md. I want to convert all those files to .html through find and the -exec option. The command to convert a markdown file to html is ...
4
votes
1answer
156 views

Why does find's -exec only executes on one result?

Here's what I checked: find mydir -maxdepth 2 -name .project -or -name .classpath gives output: mydir/.project mydir/.classpath Meanwhile find mydir -maxdepth 2 -name .project -or -name ...
2
votes
2answers
1k views

UNIX commands help - find

I'm trying to learn UNIX commands and I'm playing this game to learn and I'm really stuck at the moment. I'm in a server through ssh and the directory is full of random files and folders and the ...
4
votes
3answers
1k views

Why piping find and grep returns nothing?

I'm trying to have grep search inside specified files that are returned by find: find . -type d -name 'mydir*' -exec find '{}' -name '*.java' \; | grep 'MyClass' This doesn't work. Meanwhile, ...
15
votes
1answer
9k views

How to skip “permission denied” errors when running find in Linux? [duplicate]

Possible Duplicate: How do I remove “permission denied” printout statements from the find program? When I run this command in Linux (SuSE): find / -name ant I get many error ...
6
votes
3answers
7k views

Pipe find into grep -v

I'm trying to find all files that are of a certain type and do not contain a certain string. I am trying to go about it by piping find to grep -v example: find -type f -name '*.java' | xargs grep -v ...
4
votes
2answers
581 views

Find recursively all archive files of diverse archive formats and search them for file name patterns

At best I would like to have a call like this: $searchtool /path/to/search/ -contained-file-name "*vacation*jpg" ... so that this tool does a recursive scan of the given path takes all files with ...
1
vote
3answers
476 views

Error in Script. Command find is skipping folders with space character

I need a script that counts the files in a directory (and sub). I've taken the followed script, and changed it to my need. It works like it should, except for folders with space characters. I'm ...
10
votes
3answers
4k views

Find -exec + vs find | xargs. Which one to choose?

I understand that the -exec can take a + option to mimic the behaviour of xargs. Is there any situation where you'd prefer one form over the other? I personally tend to prefer the first form, if ...
2
votes
4answers
1k views

chown all files based on file name pattern in current directory

I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work: find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
1
vote
2answers
396 views

Search and delete .Trash

I have 4 large USB devices with lots of backups collected over the years. I want to search for all .Trash folders and delete the contents on Fedora 17. I tried the following which failed:- # ...
3
votes
2answers
722 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 ...
1
vote
2answers
2k views

Help understanding `find` syntax on Solaris

Consider the following files: $ find findtest findtest findtest/test1 findtest/test1/start.ksh findtest/test2 findtest/test2/start.ksh findtest/test3 findtest/test3/start.ksh ...
1
vote
2answers
136 views

Running 64bit OS , Find all 32bit programs on a system

How should I locate all 32bit programs on my system ? I'm running a 64bit OS. (There might be some , but I forget)
3
votes
4answers
818 views

Is there a way to increase `find` speed

I am wondering is there a way to increase find speed in terminal, it doesn't make sense that using internet google to search will have a better speed than doing a local search for strings or just file ...
1
vote
4answers
315 views

Recursively rename e-mail files from .txt to .eml

Directory "$d" contains a few thousand e-mail files with the .txt extension. To open them in my e-mail client, I need to rename them to .eml Will this command rename them correctly: find "${d}" ...
2
votes
3answers
3k views

How to find executable filetypes?

I want to find file types that are executable from the kernel's point of view. As far as I know all the executable files on Linux are ELF files. Thus I tried the following: find * | file | grep ELF ...
2
votes
2answers
278 views

find command for the newest 500 files in a directory tree and also be POSIX compliant

I am looking for a single line shell script or unix command to find the newest 500 files in a directory. Major constraints are it should be POSIX complaint and the directory can have tons of files.
2
votes
5answers
2k views

Execute on the basename of a find command

Suppose I have a directory structure as follows test test/a test/b Now I want to execute a command, such that in the . folder I can execute a command on the basename of the files a and b. So ...
4
votes
4answers
2k views

Remove numbers from filenames

I've a problem modifying the files' names in my Music/ directory. I have a list of names like these: $ ls 01 American Idiot.mp3 01 Articolo 31 - Domani Smetto.mp3 01 Bohemian rapsody.mp3 01 Eye of ...
2
votes
1answer
2k views

How to change permissions of multiple files found with find command?

I have a directory with numerous files. Part of the files have the 755 permissions and the other part have 644 permissions. I'd like to convert the files with 755 permissions to 644. I have tried the ...
1
vote
2answers
697 views

Use mogrify to resize large files while ignoring small ones

I'm running the following command: mogrify -resize '400x400>' *.png Notice the ">". Supposedly it will ignore smaller files, but although it doesn't resize them, it edits them (modification date ...
4
votes
2answers
3k views

issue with find -exec cp

Consider this example (newbie alert): touch test0 touch timestamp touch test1 sudo find /var/www/import -iname 'test*' -newer timestamp -exec cp {} new \; It actually copies file test1, but it ...
0
votes
0answers
103 views

Where is the libstdc++ test suite?

I have GCC/g++ 4.7 and it works fine. But I need to run the libstdc++ testsuite but I don't find where the testsuite is on the system and how to run it. How can I do that?
13
votes
5answers
744 views

How to remove the (1) from filenames using the find command

I recently converted all of my FLAC files to a lower sampling rate of 44.1 kHz and bit depth of 24 bits (because iPhone/iPod don't support anything above that) using XLD on my Mac OS 10.7 (Lion). ...