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

learn more… | top users | synonyms

1
vote
1answer
159 views

Wrong behavior of xargs

I was trying to solve this issue using find + xargs but I stuck with another issue I am try to increasing a count using ((a++)) but not working . I have tried couple of combination of counting a ...
2
votes
4answers
415 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 ...
0
votes
3answers
830 views

Find executable files recursively

I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command. ls -l `find ...
0
votes
1answer
209 views

Copy modified files from one server to other

Scenario: 2 Servers (*.12 and *.13) CakePHP "application" on both of them. *.12 is "Production" Server *.13 is "Development" Server Now i want to copy all files modified the last 2 days from test ...
1
vote
2answers
866 views

Find all directories, in which user has access to search and echo this directories in shell

I need to find all directories, in which user has access to search(command find) and echo this directories in shell. USER is read from ksh. for example: read user I know, if user want to use find ...
6
votes
5answers
1k views

Script to remove spaces and lowercase in file names

I am trying to write a script that will replace spaces with "-" and make all letters lower case for all files in the current directory. for x in 'ls' do if [ ! -f $x ]; then ...
3
votes
2answers
282 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 ...
1
vote
3answers
517 views

What does a question mark in a filename matching pattern mean?

What does the question mark in this command mean? find . –type d –name "?d*" –print I tried to to run it without it but didn't notice any change.
2
votes
1answer
86 views

Why is the output of find sorted in Cygwin but not in Solaris?

I wonder why find does not behave in the same way in Solaris as in Cygwin or Linux. I have a bunch of directories that have files called CS##########. Each # is a digits but there are always 10 ...
1
vote
1answer
103 views

Can this find command be made more compact?

Please look at these two commands: find ~/{Documents,Desktop,Downloads,Music,Videos} -mmin -120 -type f and find . ! -path "*opera*" ! -path "*mozilla*" ! -path "*google-chrome*" -mmin -120 -type f ...
3
votes
3answers
1k views

How to Calculate the Total size of file searched using Find command

Actually there are tow questions. First I have to search the files using FIND command that will show only the files for December 2012 And Secondly I need to see the Total size of files searched I ...
3
votes
4answers
141 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
1
vote
4answers
1k views

rsync timed out

I need to sync a directory to a directory on a remote server. at the moment i use rsync -ca to do this but the directory is quite large and the whole process fails with a timeout error. Now i'm ...
1
vote
1answer
229 views

Quoting curly braces in the shell [duplicate]

I found examples of different quoting for curly braces for find, but I could not find an explanation. The possible choices are: 1. {} 2. '{}' 3. "{}" And they all seem to work fine. Is ...
2
votes
3answers
774 views

Find directories that do not contain subdirectories

I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories. I know that I could use ls -alR and recursively parse ...
9
votes
1answer
997 views

Only find first few matched files using find?

Say there may be hundreds of *.txt files in a directory. I only want to find the first three *.txt files and then exit the searching process. How to achieve this using the find utility? I had a quick ...
0
votes
1answer
147 views

find in /sys/class does not show everything, why?

Like every other person I am from time to time compelled to list the directory structure from a certain point int the filesystem. I do so with find /path/in/fs/ and this yields something like: ...
1
vote
2answers
280 views

A bunch of files have 777 permissions

I have been learning Python and Bash scripting, and I up to now I have given my scripts 777 permissions. Having learned more about how to set permissions, and knowing this is a bad idea, I ran the ...
0
votes
1answer
626 views

Rename files and directories with a special characters on solaris machines

The target of the following code ( commands ) is to rename files/directories and also support files/directories with a special characters as "@" or "." etc those commands are run fine on Linux ...
3
votes
4answers
6k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
5
votes
1answer
928 views

Exclude directory in find

How can I find every file and directory matching a pattern, excluding one directory using find? Say I have the following file structure; . foo-exclude-me/ foo.txt foo-exclude-me-not/ ...
2
votes
2answers
251 views

Use a parameter in a command argument

I run a find command to search files with a name containing perl: find /tmp -name '*perl*' /tmp/perl.pl /tmp/run-perl-stage.pl But when I set the perl name in a variable PARAMETER and run the find ...
2
votes
3answers
1k 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 ...
4
votes
2answers
2k views

find command with regex {1,2}

I have been trying to create a find command string that will find all files that end with a number 1-99 but exclude all others. e.g. I want to find myfile1 myfile99 but not myfile456 and not ...
1
vote
1answer
427 views

How to check Today's Day and Search Files

Problem: I need to find out today's date and search a file which contain's today's date in the name. Also another file which contains Yesterday's date. I was able to do so by something like: ...
2
votes
2answers
149 views

Select greatest numbered filename

Simple requirement but can't find anything online which can achieve it. I have a list of dated files as below... filename_20120101.dat filename_20120102.dat filename_20120103.dat I ...
2
votes
2answers
411 views

find all cpp files and list only those files with names that match a pattern (regex) does not work

I have a whole repository of files and I am trying to get a list of files that match a certain criteria. For example, let us say that I want to take all the files that have the string foo1 and ...
1
vote
2answers
82 views

How to print find match as well as run an -exec

I was wanting to run a find and then execute a script on each match; however, I was wanting to print the name of the matched file above the output from each exec. How can I produce the following ...
2
votes
1answer
206 views

Find Directory and copy another directory to found directory?

I'm attempting to find a directory A that could be in a variable location and copy another directory B into the found directory. So, I'd like to find directory A, and copy Directory B into Directory ...
6
votes
2answers
390 views

Remove all Vim undo files in all but one directory

I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem ...
2
votes
3answers
222 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 ...
3
votes
2answers
2k views

find flags: -exec rm -rf vs -delete

I thought the flags I mentioned in the question are the same, but I get the following message with the former, but nothing with the latter: $ find . -mindepth 1 -type d -exec rm -rf {} \; find: ...
5
votes
4answers
11k views

List the files containing a particular word in their text

I would like to list the files recursively and uniquely that contain the given word. Example: Checking for word 'check', I normal do is a grep $ grep check * -R But as there are many occurrence ...
0
votes
2answers
523 views

How to find and replace a particular string in a specific line

I developed a code which find and replaces a specific string in all xmls under all subdirectories. But i dont want all occurances to be replaced. In entire xml, code should find the tag xyz and ...
0
votes
2answers
3k views

How to use the find command in Perl script?

Could someone tell me why the find command always go to the root directory but not the directory that is specified in $srceDir? my $srceDir = "/mnt/SDrive/SV/Capture Data/"; my $find_cmd = 'find ...
0
votes
1answer
106 views

Error trying to call find from perl

use warnings; use File::Find; my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/"; opendir(DIR, $srceDir) or die "Can't open $srceDir: $!"; my @files = (find -type f -newermt "12 Feb ...
3
votes
2answers
4k views

list all files newer than given timestamp and sort them

I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted. Using SUSE Linux Enterprise Server 11. The ...
4
votes
1answer
302 views

How to search file based on DAY of week

Actually I need to search for files and folder that were created in 2012 on Friday of every month. I did some attempts using the FIND command but it didn't work.
1
vote
2answers
869 views

Unix: find directory filenames listed in a text file and move to new directory

I'm a command line novice trying to figure out the appropriate command to execute the following within the Terminal in Mac OS X. Assuming I've placed all files in the same directory, I want to ...
3
votes
2answers
2k 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 ...
2
votes
1answer
782 views

Exclude symbolic links to other filesystems with find -mount

I am working on a script that, among other things, extracts a list of all items in a directory (files and subdirs) for archival but it needs to skip remote symlinks (i.e. on other file systems). The ...
2
votes
3answers
501 views

Howto recursively create PDF thumnbails on linux command line

I am able to use ImageMagick to create a thumbnail of the first page of a PDF using: convert -thumbnail x80 95.pdf[0] thumb_95.png This works fine and generates a thumb_95.png file. I have tried ...
1
vote
1answer
346 views

Speeding a find rm command with test through parallelization

I want to recursively delete all files in directories and subdirectories with number of lines less than 10, and am currently using the following command find . -type f -name "*.txt" | while read; do ...
2
votes
3answers
357 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 ...
0
votes
1answer
215 views

Move video files to directory by width

I'm trying to move video files to directory by width of that video file. For example I have ./xxx/pr0n.mkv ./pokemon.mkv After running script ./xxx/1920/pr0n.mkv ./1920/pokemon.mkv If I run ...
2
votes
2answers
3k views

How to find inode number using “find” command?

How do you find the inode number of the name of files that start with a particular keyword like "test"? We'll assume that there are files called: test, test1, test2.
2
votes
1answer
801 views

How to find old directories in local directory using find in AIX?

I need to find all old directories in current directory. find in AIX does not provide -maxdepth parameter. There is only -depth and -prune parameters. It is possible to write something like following: ...
25
votes
2answers
5k views

How to stop the find command after first match?

Is there a way to force the find command to stop right after finding the first match?
1
vote
1answer
818 views

Using 'find' for recursive search and delete

My queston is kind off a basic * nautilus at time cant do well at recursive search & related operations... I want to search files having name libre in them & then delete them... I am half ...
2
votes
1answer
383 views

Help me parse this `find` command

Following command tells me the length of mp4 video files: find -type f -name "*.mp4" -print0 | \ xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | \ perl -nle ...