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

learn more… | top users | synonyms

1
vote
3answers
71 views

locate alias with find

On small systems where there is no locate installed, How would an alias look like that gets the same result as locate? I can imagine find can produce the same output so an alias could look like ...
2
votes
3answers
2k views

Find functions, commands, and builtins [duplicate]

Possible Duplicate: Executing user defined function in a find -exec call Suppose I have the following bash code: !#/bin/bash function print_echo (){ echo "This is print_echo Function" ...
0
votes
2answers
3k 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 "*" ...
3
votes
2answers
112 views

To count number of matches in a mega string quickly

I have big text-data without spaces and without other rows in one line. In reality, the streams are 0.2 Gb/s, similar situation here, but in this task, counting occurrences which is more challenging ...
34
votes
3answers
12k 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
2answers
113 views

How to use logical OR in find?

In bash shell ls can use a logical OR functionality through (of course I could also do ls name1 name2 but my true examples are more complicated): ls @(name1|name2) Is there a way to do this using ...
2
votes
3answers
38 views

Find a directory which contains all the files in my list

I have moved a file, which makes a reference to four other files with the same parent directory. And now I am stock trying to figure out which parent directory that is since there a number of files ...
0
votes
2answers
29 views

How to find file that has read permissions from root directory?

I am trying to find files with read permissions from root directory and save them under /home/student/abc direcory: find / -type f -perm a+r -exec cp /home/student/abc {} + but it shows me the ...
8
votes
5answers
336 views

find | xargs shasum creates checksum of checksum file itself (prematurely) and fails when checking

My problem (in a script with #!/bin/sh) is as follows: I try to checksum all files in a directory for archival purposes. The checksum (in my case sha1) file with all filenames should reside in the ...
1
vote
2answers
40 views

Exec condition and xargs in Find simultaneously

I am trying to include the standard C package stdint.h to files which have the word LARGE_INTEGER, as a part of conversion from Windows to Linux drivers as discussed here for datatypes. I know the ...
3
votes
2answers
59 views

Script for changing modification time of files and directories recursively

I have many big folders with thousands of files in them and I want to use touchto set their modification times to be "original time"+3 hours. I got this script from a similar thread in superuser: ...
1
vote
1answer
21 views

Find folders of a given age, then filter for a given size and delete the matching folders?

I've been having trouble with this for some time. Here is what I finally came up with that seems to work, though I have very limited abilities with piping. I'm guessing this is a poor way to achieve ...
3
votes
1answer
143 views

GNU Find this but not that and do Sed?

Code find /tmp/ -type f \ \( -name "*.h" \) -o \( -name "*.cpp" \) -o \ \( \! -name "*.bak" \) -exec \ sed -i ...
0
votes
2answers
75 views

Special meaning of '{}' ';' with find

User-define action is a feature of Bash in linux. In Linux terminal if I write root@localhost: find ~ -type f -name 'foo*' -ok ls -l '{}' ';' then it checks if there is any filename starting with ...
2
votes
1answer
108 views

'Tar' the result of a 'find', preserving the directory structure

I want to tar all the *.txt files that I get as the result of a find command, that exist in a directory having a tree structure like this: Directory_name dir1 file1.pdf file1.txt dir2 ...
6
votes
7answers
9k views

Faster way to delete large number of files

I have a directory where lots of cached files are getting generated very quickly. Since these are very small files, it is consuming all my inodes very quickly. Currently I am running the following ...
1
vote
1answer
52 views

Find command fails to copy few files

I am using the command below to copy files created in the last minute. I scheduled the script which contains this command to run every one minute, so that the files can be copied as soon as the file ...
0
votes
1answer
25 views

Find directory names with N occurences of a set of characters

Sorry in advance, I know there are hundreds of posts about find, but I genuinely don't understand what's happening here and haven't been able to find a definitive answer to this question: how to match ...
3
votes
5answers
123 views

Use of find command to rename files

I have a list of 10K mp4 files some of which contains a ? mark. I need to replace these with _ (underscore). I can use find command to find these files but not sure if I can rename them. find . ...
1
vote
2answers
35 views

Utilizing The 'find' Utility - Wrong Pattern?

I've been trying to find a particular shared object within ./lib/ using the 'find' utility in the bash shell. To be more specific, to find this shared object I wanted to find all files that started ...
0
votes
1answer
42 views

How can I use sed to find a string and replace another string on a different line? [closed]

I have a file like this: BEGIN Name "TIPO_RECORD" SqlType "12" Precision "255" Name "Test" SqlType "12" Precision "255" Name "xxxx" SqlType "12" Precision ...
0
votes
1answer
29 views

How do I find a directory or a file in Linux file system [closed]

I am using the find command in my Android image; a image which I developed myself and put in an example of a dynamically loadable module. I put the code in the /example directory of my source code, ...
4
votes
2answers
110 views

Difference between find ~ and find *

What is the difference between find * and find ~ for searching a file? In terminal when my present working directory on root,then in terminal root@devils-ey3:~# find * -print -quit ~ On same ...
3
votes
1answer
68 views

Filename Expansion: Find Utility Pattern Matching vs Bash Shell Pattern Matching

For filename expansion, the 'find' utility's '-name' option seems to function similarly, but not exactly the same as the bash shell's builtin pattern matching. Here are the relevant sections of the ...
5
votes
2answers
535 views

Can the “find” command work more efficiently to delete many files?

I want to delete old files in a directory that has a huge number of files in multiple subdirectories. I am trying to use the following - after some googling it seems to be the recommended and ...
2
votes
2answers
27 views

In find -perm, what's the difference between “+6000” and “/6000”?

I'm trying to find all the setuid/setgid binaries on my system. I've found two different ways to do this online. What's the difference between find / -perm +6000 -type f and find / -perm /6000 ...
1
vote
1answer
18 views

How do you use 'find' to update ownership of all directories, files, and symbolic links in a folder?

I'm trying to update the ownership of everything in a directory tree from me to root. I'm using find to do it a little more carefully than a recursive chown. Here are the commands I use to change ...
2
votes
3answers
124 views

Find command returns different results when -print0 is added

When doing a search like find -type d, adding the -print0 argument right after the find command such as find -print0 -type d causes the search to return more results than without it.
1
vote
1answer
56 views

piping commands after a piped xargs

HP-UX ***** B.11.23 U ia64 **** unlimited-user license find . -type d -name *log*|xargs ls -la gives me the directory name(the ones which contain log in the directory name) followed by all files ...
1
vote
1answer
30 views

Trying to find all files in certain directory that are not referenced in other files

I have this project that has a images folder with images in them and I'm pretty sure some of them are not used. So I'd like to list all images that are not referenced in any other file. I'm not very ...
2
votes
2answers
54 views

is it possible to search for files that have a special Linux file attribute?

is it possible to search file in the linux OS that have particular file attribute as this: ---S--l--- ---S--l--- 1 root root 0 Mar 1004:25/opt/csTuner/iba/wys/tuer_lolk What is S in ...
18
votes
6answers
19k views

Sorting files according to size recursively

how to scan a folder recursively and find the largest files in the folder, and sort them by size. I have tried using ls -R -S but it tends to list the directories as well I need to scan the folders ...
1
vote
2answers
127 views

find: prune does not ignore specified path

I need to exclude .git from my find search. To achive that, I am using the -path ./.git -prune switch: $ find . -path ./.git -prune -o \( -type f -o -type l -o -type d \) | grep '.git' ./.git ...
14
votes
4answers
23k views

Recursive grep vs find / -type f -exec grep {} \; Which is more efficient/faster?

Which is more efficient for finding which files in an entire filesystem contain a string: recursive grep or find with grep in an exec statement? I assume find would be more efficient because you can ...
4
votes
2answers
121 views

find and negation of an -iname condition

I am trying to find all the files which have 'pillar' in the name (case incentive) and do not contain 'cache' (also case insensitive) with find . -iname '*pillar*' -and -not -iname '*cache*' but it ...
9
votes
4answers
22k views

How to delete directories based on `find` output?

I issue the following command to find the .svn directories: find . -name ".svn" That gives me the following results: ./toto/.svn ./toto/titi/.svn ./toto/tata/.svn How could I process all these ...
20
votes
9answers
2k views

Find files whose name is 4 characters long

I would like to find files whose name has only 4 characters. Example, there are three files under /tmp: $ ls /tmp txt file linux Output should only show file because it only has 4 characters.
1
vote
2answers
74 views

ls or find option to exclude binary files

How can I list only files that aren't compiled code in the current directory? I'm reviewing the custom scripts and code on several HPUX and Linux servers before transferring them to a newer system. ...
1
vote
2answers
44 views

Find file which name contains given substrings simultaneously

In general, it's often needed to find a file whose name should contain several substrings simultaneously. How do I do that with bash? For example, "boost", "qt" and "linux" in a file called "How to ...
0
votes
2answers
63 views

Shell Script: Use “find” to execute shell a command that contains “filename”(without extension) returned from “find”

I have several files with extensions "*.f90" in directory-A. I want to apply the following command for each file in shell script. e.g. filename.f90 f2py -h filename.pyf -m filename ...
18
votes
6answers
4k views

find searching in parent directories instead of subdirectories

I'm nested deep in a file tree, and I'd like to find which parent directory contains a file. E.g. I'm in a set of nested Git repositories and want to find the .git directory controlling the files I'm ...
0
votes
1answer
24 views

Copying files containing specific text preserving directory structure

Using the code in this answer, I can easily copy a file containing specific text from one folder to another. With the -r option I can also search inside directories recursively. The result is that ...
3
votes
1answer
92 views

Find, count and sort all audio files. ALAC (M4A) files

I'm putting a script together to sort a very large music collection. It's approx 22000 albums, a mixture of FLAC, WAV, AIFF, M4A (AAC & ALAC). So far, I can sort by file type and get a total size ...
1
vote
2answers
30 views

searching for files with multiple strings (all inclusive, not one or the other ) and print line numbers

I want to search for 2 (or more) strings across the files of a certain directory and print the line numbers. The search results should include only those files where all the mentioned strings are ...
1
vote
3answers
56 views

How can I replace string in all files in a directory and all sub-directories without changing any of the hidden directories/files?

I am using the following command find . -type f -exec sed -i 's/_backpack.html/_backpack_cal.html/g' {} + I expect all "_backpack.html" strings in my project to be replaced to _backpack_cal.html ...
4
votes
3answers
79 views

Find largest files from each date in a directory

I have a directory similar to the following: -rw-r--r-- 1 root root 223K Apr 28 14:25 2015.04.28_14.25 -rw-r--r-- 1 root root 253K Apr 28 14:55 2015.04.28_14.55 -rw-r--r-- 1 root root 276K Apr 28 ...
0
votes
1answer
28 views

Openssl on files found with find unix command

Total noob with shell scripting here. I can find the files I'm looking for with something like this: find . -name "*.mp3"; What I want is something like this: find . -name "*.mp3" -exec openssl ...
1
vote
1answer
45 views

Stopping find command after finding files in one directory

I have a command in a Korn script which is like as written below, find <path1> <path2> <path3> -name filename After this, it stores the output in a txt file. Using this txt file ...
1
vote
4answers
43 views

What is the best way to delete files & folders in a directory excluding the contents of one folder? [duplicate]

I'm trying to automate some file house keeping I do pretty often. I want to delete all of the files and folders in a directory while excluding the folder "./xfer" and its contents. I've bee trying ...
12
votes
6answers
2k 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. ...