find is a command line utility to search for files in a directory hierarchy
0
votes
2answers
29 views
Why don't find and locate search /bin?
What gives? Normal find and locate commands don't turn up the verify program that lives at /bin/verify. In fact, it seems they don't turn up anything that lives in /bin
[jake@jace]/bin% "find" /bin/ ...
6
votes
1answer
95 views
find is missing a result — how is that possible?
What conditions explain this output:
root@ip:/# find / -name "server.xml" -print
/etc/tomcat7/server.xml
root@ip:/# ls /var/lib/tomcat7/conf/server.xml
/var/lib/tomcat7/conf/server.xml
I am ...
2
votes
3answers
46 views
Passing multiple directories to the -prune option in find
I am using find to locate and delete backup files but wish to exclude certain directories from the search. The backup filenames could terminate in .bck, bak, ~, or backup.
The Minimal Working Example ...
1
vote
1answer
46 views
chmod allowing write when I am not setting it
I've got a perl script which systematically changes permissions. The first thing the script does is remove all permissions. It does this by calling chmod(from perl). I did this as I found the set guid ...
1
vote
2answers
108 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
...
1
vote
0answers
55 views
Find command incorrect results with days filter
I am trying to find all files modified before march 6 in a directory with thousands of files.
I executed the following commands in the PWD where I want to find files.
find -mtime +47 > ...
2
votes
4answers
77 views
How to move the files based on Year
I need to move files based on a year. I used the find command
find /media/WD/backup/osool/olddata/ -mtime +470 -exec ls -lrth {} \;|sort -k6
but for this command to successfully execute i need to ...
4
votes
1answer
66 views
Execute multiple bash commands on the output of find
I want to execute some commands using the find -exec option, but I'm not sure what' wrong with this code. Currently, it's only processing the first find result, then getting stuck. I'm using bash in ...
1
vote
2answers
40 views
Delete n minutes old file in solaris
Can some one please tell me how to delete n minutes old files in Solaris? My find does not -mmin option.
1
vote
3answers
61 views
find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664; does not work
I am using this command to set permissions for files recursively
clime@vm6879 /srv/www-php/steeltrading $ find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664
But after executing that command ...
5
votes
3answers
123 views
Use find result without ./
I'm trying to use find to create a bunch of symlinks but using the result with {} includes ./ before each filename. How can I avoid that?
find . -type l -name '*.h' -exec ln -s /sourcedir/{} ...
1
vote
4answers
102 views
Is there a command to list files, exclude sub-directories and display size and date?
Before I begin please assume I have only basic knowledge in UNIX. Basic meaning I have only started reading about it since last week for a work related purpose.
I have been experimenting with the ls ...
4
votes
2answers
65 views
remove duplicate files
On my Mac OS X 10.6.7, iTunes duplicated every single file in my music library. Now I have 3,840 files instead of 1,920. The problem is that iTunes didn't simply duplicate the whole folder, but each ...
1
vote
3answers
101 views
Why is this Bash command using regex not replacing my brackets?
I have this command to go through all my files in my Music directory, and all subdirectories, and replace any square brackets in the file name with rounded brackets:
find /home/Music/ -depth -name "* ...
0
votes
3answers
45 views
How to find files ending with ~ and pyc? [duplicate]
I want to find all files (in current and all subdirectory) which end in'~' or 'pyc'. To do so I have tried the following find pattern:
find . -name '*{~,pyc}'
find . -name '{*~,*.pyc}'
but neither ...
1
vote
1answer
71 views
What is a sure fire way to find all files and/or path that contains 2 keywords?
I was doing a
find . -iname '*sitesearch*' | grep demo
because I know the file should be some/path/SiteSearch/demo/SiteSearch.html, but it turned out a person put the file in as ...
3
votes
2answers
182 views
How to use find to remove *.py~ and *.pyc files at once?
I want to cleanup a directory (and subdirectories) from each occurrance of the .py and .pyc files. I tried the following
find . -name '*pyc' -o -name '*py~' -exec rm -f {} \;
which left out all pyc ...
17
votes
4answers
619 views
Howto find duplicate files on disk
Is it possible to find duplicate files on my disk which are bit to bit identical but have different file-names?
1
vote
1answer
63 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
99 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
63 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
24 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 ...
0
votes
1answer
63 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 ...
4
votes
5answers
189 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
81 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
118 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
47 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
62 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
69 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 ...
2
votes
3answers
82 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
0
votes
3answers
67 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
52 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
4answers
85 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
200 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
44 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
96 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
174 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 ...
2
votes
4answers
183 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?
4
votes
1answer
40 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
67 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
77 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 isnt illegal on solaris
what the equivalent option ( xargs ? ) for solaris 10
second ...
3
votes
2answers
55 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
59 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
53 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
94 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
51 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
44 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 ...
5
votes
2answers
99 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
69 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
183 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: ...