find is a command line utility to search for files in a directory hierarchy
0
votes
3answers
110 views
Find modifies the Access Time
I have to find those files which have been modified before one day. There are lots of files which are modified before one day. I am doing find ./ -type f -mtime -1. But, I observed that my disk util ...
2
votes
2answers
104 views
Sort the output of find before piping to openssh
I'm using this command to recursively generate a SHA-512 hash for each file in a directory hierarchy:
find . -type f -exec openssl sha512 {} \;
I'd like to sort the files in lexicographical order ...
1
vote
1answer
108 views
questions on find and grep
With respect to the following find command-line
find . -type f -exec grep -l strings {} \;
I do not understand the usage of -exec and {} \ Thanks.
3
votes
3answers
467 views
bash - can I do : find … -exec this && that?
Is there a way to logically combine two shell commands that are invoked with find - exec?
For instance to print out all the .csv files that contain the string foo together with its occurrence I would ...
1
vote
2answers
89 views
How to find which files contain mentions of a wildcard image name?
What I am trying to do is do a search on my server to find which files contain mentions of images with a certain keyword in the filename but all I can figure out is how to find the filenams (not image ...
1
vote
4answers
481 views
Checking if a file exists in several directories
I've been working on this far too long and need some help.
I need a script that will look at files in a directory and see if it exists in one of several directories.
I need something like this:
for ...
17
votes
1answer
648 views
Why doesn't 'find' show this file?
Using find with grep, one can locate files that match a pattern:
# find | grep error
./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html
./error_log
./includes/classes/error_log
However, using ...
1
vote
1answer
279 views
find and globbing (and wildcards)
I tried finding some files (*.e*) that are in the same directory as another file (md.tpr). I needed to list them (for further processing) using the following:
find . -name md.tpr -execdir ls *.e* \;
...
2
votes
3answers
79 views
Why is find looking in the current directory?
I have a bash script /var/www/scripts/process_sounds.sh that uses the command:
find /var/www/unprocessed_sounds/ * -type f
It's supposed to find all the files in the unprocessed_sounds directory, ...
1
vote
1answer
70 views
Find both regular files and directories
How can I tell ( if I can tell !) find to find files of both the directory and file type?
find -type fd
It is like the heuristic dark ages up in here.
0
votes
2answers
198 views
Passing results of “find” to zenity
The result of the following script:
results=$(find -iname "*.mp4")
echo $results;
is something like:
file1 file2 file3
How do I pass the results of the find command to a variable, as it is shown ...
5
votes
1answer
142 views
How can I synchronize all PDFs from one directory with Dropbox?
I want to synchronize all the PDFs from one directory (my Zotero library) to Dropbox. Finally, I want to have a list of all the PDFs, not the directory names.
I successfully synchronized all my PDFs ...
4
votes
2answers
563 views
How to return both file name and line number with find … -exec grep?
When using find, how do I return the file name and the line number when searching for a string? I manage to return the file name in one command and the line numbers with another one, but I can't seem ...
1
vote
3answers
159 views
find with user variables
I am trying to call find with a few variables. So far I had this:
DIRECTORY="./ "
FILENAME=-regex" .*test.*"
find $DIRECTORY $FILENAME
Which works fine. If I change the filename to :
...
6
votes
4answers
287 views
Find images by size: find / file / awk
I've been trying to find png image files a certain height (over 500px). I know that file will return image dimensions. Example:
$ file TestImg1a.png
TestImg1a.png: PNG image data, 764 x 200, ...
1
vote
3answers
787 views
Linux: Does find | xargs grep have limitations?
I've historically performed something like:
find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null
If my pwd is barfoo (/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. ...
6
votes
2answers
151 views
du command show a slash after directories?
How to use du command show a slash after directories?
For example:
du -ab /root/test/php-5.4.8/
Result:
1781 /root/test/php-5.4.8/main/internal_functions.c.in
973596 ...
1
vote
2answers
109 views
Extracting a multiline regex without leading tabs
I've been trying to hack a little code extraction script together, but I can't get it to work.
My goal is to examine all .txt files in a directory. If it contains a line which doesn't start with a ...
1
vote
3answers
254 views
Compacting `find` name patterns
I am using
find . -name '*.[cCHh][cC]' -exec grep -nHr "$1" {} ';'
find . -name '*.[cCHh]' -exec grep -nHr "$1" {} ';'
to search for a string in all files ending with .c, .C, .h, .H, .cc and .CC ...
3
votes
2answers
844 views
Bash: How to read one line at a time from output of a command?
I am trying to read the output of a command in bash using a while loop.
while read -r line
do
echo "$line"
done <<< $(find . -type f)
The output I got
ranveer@ranveer:~/tmp$ bash ...
2
votes
1answer
167 views
Web front-end to find/grep/ack
In my lab, we are trying to build a web that allows the user to enter queries for find, ack, grep on a specific directory. The web would return an HTML with a table of a list of clickable files (click ...
5
votes
2answers
218 views
Find files that were not installed by the package manager
I'd like to get a list of all files in my Gentoo Linux system that were not installed by the package manager (Portage). This is because I want to keep my system as clean as possible, removing all ...
4
votes
1answer
191 views
find . -size -1GB in Centos
In Centos, I have a text file in my home directory.
The command find . -size -1M doesn't show my file but find . -size -1000k does show it. This problem just seems to be happening when I use the ...
7
votes
4answers
962 views
Executing user defined function in a find -exec call
I'm on Solaris 10 and I have tested the following with ksh (88), bash (3.00) and zsh (4.2.1).
The following code doesn't yield any result:
function foo {
echo "Hello World"
}
find somedir -exec ...
12
votes
3answers
511 views
How to combine 2 -name conditions in find?
I would like to search for files that would not match 2 -name conditions. I can do it like so :
find /media/d/ -type f -size +50M ! -name "*deb" ! -name "*vmdk"
and this will yield proper result ...
2
votes
1answer
120 views
How to find files compared to the time of a specific file
How can I search for files that were modified or changed 5 minutes before and 5 minutes after, a certain file. I have tried
mint@mint ~/Desktop $ touch -t 201210101315 /tmp/timestamp
mint@mint ...
1
vote
4answers
119 views
Syntax error in a bash script that calls find
Where is the error in this script please:
#!/bin/bash
rep="git"
files=`find' ${rep} '-type f`
for f in ${files} do
echo $f
done
When i run find git -type f alone in the shell, it works!
3
votes
5answers
461 views
How do I perform an action on all files with a specific extension in subfolders in an elegant way?
My current best bet is:
for i in $(find . -name *.jpg); do echo $i; done
Problem: does not handle spaces in filenames.
Note: I would also love a graphical way of doing this, such as the "tree" ...
2
votes
2answers
98 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 ...
3
votes
2answers
186 views
List files created on Sundays
How do I list/find all the files created on Sundays or Mondays?
How do I use the date parameter to display them?
Something like :
ls -f date + %a
or
find -type f | date +%A
or
find -type f ...
4
votes
2answers
370 views
Reformatting a large number of XML files
I'm manipulating a large number of XML files scattered throughout a nested directory structure. I tried the following (which almost works):
$ find . -name "*.xml" -type f | xargs -- xmllint --format
...
5
votes
3answers
3k views
Find files which are created a certain time after or before a particular file was created
I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt) was created.
If I go with find -newer, that means I'd have to create a temporary ...
7
votes
2answers
205 views
Search MP3/Ogg files by tags/parameters from the command line
Is there any utility to search MP3/Ogg files by tags (or other characteristics) from the command line? (e.g. finding all audio files longer than 10 minutes with genre set to 'Rock').
I found this, ...
7
votes
1answer
279 views
Got less output with print0 option on find?
I have read the man page and other references, but I am still confused by the behavior of find with -print0 option.
-print0 This primary always evaluates to true. It prints the pathname of
...
1
vote
2answers
244 views
Auto-expansion problem with array elements containing an '*' (asterisk)
I'm trying to write me a find script that should later be able to read a list of directories to be excluded from an external file. Whilst I can accomplish that part myself, it's the annoying array ...
4
votes
2answers
258 views
Passing parsed output of sed to find (in this direction)
Well, I think you can find dozens of questions on this platform how to pipe find output to sed, but I haven't found anything for the reverse direction so far. What I want to do is modify my input, and ...
2
votes
2answers
259 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". ...
-4
votes
2answers
396 views
How to find a file containing a string? [duplicate]
Possible Duplicate:
How can I find a file whose name includes a given string, such as “abcde”?
How to find files in terminal that contains the string "foo"?
I tried the ...
4
votes
2answers
127 views
Dealing with script interruption
I need to iterate over between 120k and 500k files. find handles this well.
find $PWD -type f -path "fragments/*.pdbqt"
For some reason I want to list the same set of files again, in the same ...
3
votes
2answers
185 views
List of top level folders with contents no younger than 30 days
I have an automated system for creating FTP accounts (vsftpd with jailed virtual users) that works well, but I still rely on manual cleanup of stale accounts.
My definition of a stale account is one ...
2
votes
2answers
261 views
Running sha1sum into several directories
I have several directories that share a common parent directory. In each directory there are regular files, but no other subdirectories. Something like this:
top/dir-1
top/dir-1/file-11
...
2
votes
3answers
140 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
331 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
92 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
188 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 ...
8
votes
6answers
1k 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 ...
3
votes
1answer
1k 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" {} \; | ...
5
votes
4answers
3k 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
469 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
1k views
how to find (and delete) all empty directory in my home directory recursively? [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.
...

