find is a command line utility to search for files in a directory hierarchy
1
vote
2answers
22 views
Variable scope in multiple pipes
I was trying to do something following,
find . -name "*.dat" | get the basename of file | move filename returned by first command to basename returned by second command
To give a concrete example, ...
2
votes
4answers
46 views
find command: how to ignore pathname?
I have to find some type of files in a directory and it's subdirectories and I only have to print out the filenames.
So here's the main command:
find -type f -name "*.c"
Now, how could I cut the ...
3
votes
3answers
108 views
Concatenating thousands of files: > vs >>
I found two seemingly contradictory answers on StackOverflow to the following questions:
Concatenating Thousands of Text Files Across Hundreds of Directories (while keeping some structure)
How do I ...
1
vote
3answers
71 views
Setting file permissions in bash script
This script is not working the way I thought it would .I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5
#!/bin/bash
# the / makes find ...
2
votes
2answers
39 views
How to find files with a certain subpath?
I need to find all xml-files that are placed in folders named config. Also config must be somewhere under a folder named trunk. For example, I am interested in all files like below:
...
1
vote
3answers
39 views
Apply two commands to result of find
I am trying to apply two command (echo and haml --check) to result of my find.
haml --check `find . -name "*.haml"`
# return Syntax error on line 2: Illegal nesting: nesting within plain text is ...
0
votes
1answer
52 views
How do I redirect output from the find command (that uses grep) to a log file?
Consider the code to search for all files containing the pattern "search string":
bash-3.2$ # The below find works fine..
bash-3.2$ find . -type f -exec grep -il "search string" {} \;
bash-3.2$ # But ...
2
votes
2answers
70 views
Exclude all subdirectories except one specific path in a find command
I use a find command to search for all files with a given extension within the current subdirectories ignoring certain directory path:
find -L . \( -wholename "*/ignoredPath" -o -wholename ...
2
votes
4answers
95 views
Find and copy directories containing file type
I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc.
I'm trying to copy all directories containing ...
6
votes
1answer
55 views
How to do `head` and `tail` on null-delimited input in bash?
find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
1
vote
2answers
61 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
113 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
66 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
51 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 ...
2
votes
3answers
137 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
59 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
84 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
78 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
61 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
72 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
127 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
148 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
89 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
122 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
48 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
77 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
188 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
704 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
67 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
105 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
71 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
33 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
72 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
242 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
91 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
138 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
49 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
63 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
83 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
83 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
83 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
63 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
99 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
214 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
56 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
107 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
196 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
311 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
44 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
73 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 ...
