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

learn more… | top users | synonyms

0
votes
1answer
125 views

Alter path of find result [duplicate]

Possible Duplicate: Manipulate file name piped from find command How can I alter the path of a file found with find before I run an exec on it? I want to find files and then mv them to a ...
3
votes
1answer
881 views

Recursive find that does not find hidden files or recurse into hidden dirs

I am wanting to search recursively through a directory and find all files that are not hidden files themselves and are not in a hidden dir. I tried using find . -type f -not -name '.*' which excludes ...
2
votes
1answer
438 views

How to have find recurse into subdirectories when using -prune option

I see that the find command does not descend into subdirectories when you're using the -prune option. How do I tell find to recurse into the sub directories, but also ignore some stuff? ...
2
votes
2answers
538 views

comm fails on bash variable input

I have a script that's supposed to get the list of files of two directories, get differences and execute some code for certain files. These are the commands to get the file lists: list_in=$(find ...
1
vote
2answers
2k views

Command to find file/path lengths that are too long for burning to DVD?

I'm trying to burn a DVD from Windows but it fails because the full path name length exceeds the limit of something like 255 characters. Our files are stored in Debian Linux (accessed by Windows ...
2
votes
5answers
143 views

Find folders containing a file

How can I find all subfolders containing a given file? For example, in a Minecraft server installation, the different worlds are stored in subfolders with arbitrary names. To identify that a given ...
3
votes
5answers
3k views

Find files in multiple folder names

I am trying to list all the files from dir1, dir2, dir3 and dir4 which might be anywhere in as a sub directory of my cwd using the find command. I tried the following with no success: find . -type f ...
2
votes
2answers
397 views

Get total size of jpeg images per directory in each directory containing jpegs

I'm trying to get a per-directory total size of all the .jpg/.jpeg images in each directory that contains such images. And showing the full directory path. I'm no bash expert but I've managed to ...
0
votes
2answers
1k views

variables in find command and more shell problem [duplicate]

Possible Duplicate: Recursive rename files and directories I wrote the following script: #!/bin/bash SAVEIFS=$IFS alias export='export' IFS=$(echo -en "\n\b") find $1 -name "*" ...
2
votes
1answer
124 views

IOStat report large ocassional writes but find reports no big file

root@host [/home4]# find . -type f -size +2000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' ...
1
vote
2answers
672 views

What is wrong with this call to sed -i?

I have this line find . -type f \( ! -name '*.plist' \) -and \( ! -name '*.mp4' \) -and \( ! -name '.DS*' \) -print0 | xargs -0 sed -i 's/AAA/BBB/g' my intention is from the current directory ...
2
votes
3answers
2k views

Manipulate file name piped from find command

I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
27
votes
3answers
3k views

locate vs find: usage, pros and cons of each other

In Linux and Unix systems there are two common search commands: locate and find. What are the pros and cons of each? When one have benefits over the other?
5
votes
5answers
2k views

Delete all folders containing files which match pattern

I'm trying to delete all subdirectories of my current working directory which contain a rar file. My first attempt: find -name *.rar -exec rm -r {}/.. ';' failed because that is not a valid ...
1
vote
0answers
56 views

GUI for find which can show video thumbnails

Is there a GUI for find (or just a graphical search tool which supports regex searches on filenames starting from a specific directory) which is able to show thumbnails found video and image files? I ...
1
vote
2answers
148 views

find “an expression” on each file of a directory recursively

One of my website on my webserver has suffered an attack : code injection. Here is the malicious code : <script type=\"text/javascript\" language=\"javascript\"> (function () { var t ...
4
votes
3answers
3k views

Preserve directory structure when moving files using find

I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly. #!/bin/bash echo "Enter Your Source Directory" read ...
10
votes
5answers
881 views

How to find files with 100% NUL characters in their contents?

What is the Linux command-line command that can identify such files? AFAIK the find command (or grep) can only match a specific string inside the text file. But I want to match whole contents, i.e. ...
-1
votes
1answer
136 views

Error while running bash script that moves files

I am new to bash script and want to create bash script that moves some days old files between source and destination as per days defined in script. When I run this script I get error find: paths ...
6
votes
1answer
467 views

tar: how can I exclude intermediate directories but include leaf directories?

I want to create a tar file suitable for extracting into /. I've created a work directory that represents the root of the file system, and it has all the stuff I want included in the tar underneath, ...
2
votes
2answers
6k views

Compress old log file into single zip-linux

I have a folder /home/testuser/log which contain log files of one day old *.log. I wish to compress all the log files older than one day to a single zip(gzip or tar.gz) and delete the older files. I ...
2
votes
1answer
87 views

Find: Reference to Current Directory

I'm trying to use find with the regex option. However my regular expression only captures the basename of the file. Is there a reference to the "directory find is currently in" I can use in my regular ...
0
votes
3answers
222 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
339 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
128 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 {} \.
4
votes
3answers
1k 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
201 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
1k 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 ...
19
votes
1answer
703 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 ...
2
votes
1answer
1k 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
92 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, ...
2
votes
1answer
156 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
381 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
192 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 ...
6
votes
2answers
4k 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
680 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
5answers
993 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
2k 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
184 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
129 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
949 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 ...
7
votes
2answers
8k 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
2answers
309 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 ...
6
votes
2answers
646 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 ...
5
votes
1answer
678 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 ...
10
votes
4answers
3k 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 ...
17
votes
3answers
4k 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
158 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
178 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!
4
votes
5answers
2k 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" ...