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

learn more… | top users | synonyms

2
votes
4answers
68 views

print parent directories full path of find output

what I want to do is to find all files based on some search query and get parents parent directory (../..) full path. For example find . -name "__openerp__.py" and then for each file execute ...
2
votes
4answers
118 views

Using a generated list of filenames as argument list — with spaces

I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this: $ myscript `find . -name something.txt` The problem is that some of the pathnames ...
2
votes
2answers
56 views

Pipeline with grep and find prints numbers infront of result

Am using the following "find" command to extract some files, find /lag/cnnf/ -maxdepth 3 -newer ./start ! -newer ./end | grep -nri abc | egrep '([^0-9]45[^0-9])' | grep -nri "db.tar.gz" >> ...
2
votes
2answers
198 views

Optimized way to list and delete files

I need to list and delete .php, .xml files. For this I am using find command. To list : find . -type f -name \*.php -print0 To delete : find . -type f -name \*.php -print0 | xargs -0 rm -r As I run ...
2
votes
3answers
268 views

Use find + sed + cp to find files and copy them to a directory with a different name

I'm trying to copy a bunch of files named folder.jpg into a folder. The problem is because all the files are named the same thing, I need to rename them in the process. I know I can probably do it ...
2
votes
3answers
3k views

How to delete files filtered out by awk

I have the following files in a directory: -rw-r--r-- 1 smsc sys 46 Apr 22 12:09 bills.50.1.3G.MO.X.20120422120453.Z -rw-r--r-- 1 smsc sys 28 Apr 22 12:15 bills.50.1.3G.MO.X.20120422120953.Z ...
2
votes
2answers
770 views

Is There A Way To Find Files Containing Only Non-Printing Characters?

I've got a program that's behaving badly and has created a number of files with only a few non-printing characters. If I were to cat the files, I see nothing (since they are non-printing chars). ...
2
votes
3answers
1k views

create md5 hash from a recursive file listing when some paths have spaces

I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path. I am ...
2
votes
3answers
98 views

How to find every file that includes a given function?

I am trying to list all of the files that include a function, e.g., matrixCal. How can I to do this in linux?
2
votes
5answers
105 views

Find all files that have been last modified on a specific day - like Monday?

So I want to use find to return a list of all .html files in a given directory that have been last modified on a Monday. How can I do this?
2
votes
2answers
56 views

help with truncate \ find

This command won't work: $ truncate -s 0 $(find . -size +1c type -f -exec grep -LwE 'keyword1|keyword2|keyword3' {} +) "find: paths must precede expression: type Usage: find [-H] [-L] [-P] [-Olevel] ...
2
votes
2answers
79 views

Understanding -regex with GNU find

Background I have what I think should be a simple case. I want to find all files with "cisco" in the name and do something with those files (via xargs). Finding files with ls Before I use xargs, ...
2
votes
4answers
141 views

Recursively apply a command to modify all files in a directory

I have a command that reads a file, and outputs a modified version on stdout: ./convert /path/to/file How can I recursively apply this command to all files in a directory, and overwrite the ...
2
votes
2answers
63 views

open a file and copy the listed files to another folder

I have a file named file1.txtcontaining file names like below : filea.txt fileb.txt filec.txt I want to copy the files listed in file1.txt to another folder. What is the UNIX command to use? (the ...
2
votes
4answers
246 views

Scope of variables when calling function from find

In a bash script I define a function that is called from find. The problem is that the scope of variables does not extend to the function. How do I access variables from the function? Here is an ...
2
votes
3answers
998 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"? ...
2
votes
3answers
101 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
2answers
470 views

How to copy a piped list of files contained spaces and apostrophes?

I have a list of files generated using find that I want to feed (pipe) to cp. My problem is that the files have spaces and apostrophes in them, leading cp to repeatedly complain that it "cannot stat". ...
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 ...
2
votes
1answer
545 views

How to find every symbolic link on a server?

I need to find every symbolic link on the server. The version is AIX 6.1. man find says -L Follow symbolic links But find -L is not a proper usage. Usage: find [-H | -L] Path-list ...
2
votes
4answers
3k views

Deleting Lines Containing a Specified String in Different Files

Suppose there are two files in web/ named foo.php and bar.php. The 1st line of foo.php is "sdajgeSTRINGdsad" and the 10th line of bar.php is "gdfhu98324STRING". The task is to first locate these two ...
2
votes
3answers
50 views

using regex with find

Let's say I need to find all files in /var/log/ except btmp, lastlog, wtmp. And I only need depth 1. I tried with the following find command, but that does not work as expected: find /var/log/ ...
2
votes
2answers
65 views

Rationale find command display . directory

I am wondering what the reason or rationale is for the find command to list the current directory ( . ) at some times but not others. When I use ".", I see the current directory in the outer ...
2
votes
4answers
259 views

Zgrep stop after first match when arguments are passed from xargs

I'm using this command to find patterns in zip files (similar to the one) suggested here http://superuser.com/questions/144926/unix-grep-for-a-string-within-all-gzip-files-in-all-subdirectories find ...
2
votes
2answers
551 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" ...
2
votes
3answers
105 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 ...
2
votes
1answer
48 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 ...
2
votes
2answers
709 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
3answers
233 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 ...
2
votes
2answers
164 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 ...
2
votes
3answers
814 views

`solaris + xargs command for solaris

the command find /tmp -name 'core*' -type f -print0 | xargs -0 works fine on Linux, but xargs -0 option is not legal on Solaris what is the equivalent option ( xargs? ) for Solaris 10 second ...
2
votes
3answers
191 views

How to copy a list of files and adjust destination filenames on the fly?

When I don't need to adjust destination filenames I can do something like this: $ find -type f -name '*.pat' -print0 | xargs -O cp -t /path/to/dest It is safe because the filenames may even ...
2
votes
3answers
330 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.*"
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
4answers
6k views

How to find the total number of occurrences of text and files with find command

I am trying to run the find command to find the total number of occurrences of a particular text string and also the number of files which has this text string. What I have right now is this command. ...
2
votes
1answer
82 views

Find font file from font name on Linux

I have a font with the name Media Gothic. How can I find the file name of that font in Linux? I need to copy that file to another system. I've tried: find /usr/share/fonts/ -name '*media*' But this ...
2
votes
2answers
23 views

Search for files by content only in trunk subdirectories

I think its a simple question, but the answer is probably a little more complicated :P Edit: Actually, its not complicated at all!^^ So I have a directory with multiple svn projects and I would like ...
2
votes
2answers
59 views

How to get directories and and subdirectories count fastest way?

I want to get the number of directories and sub directories.I tried following command which takes very long time . I tried waiting about an hour to finish the command. commands I used $ find . -type ...
2
votes
2answers
71 views

Trouble getting regex to work with find

I'm having a lot of trouble getting find to work with regex flags. Im using egrep on its own to find a date pattern in a file, like this: egrep '[0-9]{4}-[0-9]{2}-[0-9]{2}' which will return dates ...
2
votes
2answers
91 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 ...
2
votes
2answers
161 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 ...
2
votes
4answers
236 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 ...
2
votes
2answers
133 views

What is an equivalent of rm `find lib/ -name *.swp` without find?

As in the title, I would like to remove all files in the lib directory with .swp in the end. How can I do this without find in: rm `find lib/ -name *.swp`
2
votes
2answers
136 views

How can I enhance the output of find and grep?

I really don't look forward to having to do find/grep because the output, as returned by find . -exec grep sometext {} \; -print is just not very easy to read even when you dump it in a file. What ...
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 ...
2
votes
3answers
2k views

How can I loop through lines of a file and find files matching each line?

In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop ...
2
votes
4answers
58 views

Find + Grep Recursive Search

I am mirroring a website using wget. On the server, there is a dump of the find / command, which includes filenames in the form : /dir1/ /dir1/page1.txt /dir1/page2.txt ... The mirrorring is very ...
2
votes
2answers
20 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 ...
2
votes
1answer
40 views

Combining options in find command

Using the find command is there a way to combine options: i.e. find . -type fd -name "somefile" Although -type ignores the second option; I'm looking to find only files or directories.
2
votes
1answer
44 views

size option in find(version 4.4.2) does not understand kilo prefix

For some reason, find does not seem to accept kilobytes prefix: T42 ~ # find /root/ /home/noc/ \( -type f -size -1k \) -exec grep -iH hangup {} \; find: `/home/noc/.gvfs': Permission denied T42 ~ # ...