Tagged Questions

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

learn more… | top users | synonyms

2
votes
2answers
28 views

Finding duplicate files by name ignoring the case in subdirectories

How is it possible to list duplicate file names on a Linux system ignoring the case including all subdirectories Files should not be compared by their content but only by their names. The output ...
4
votes
4answers
332 views

Text files containing their own name

I need to find in certain directory and all its' subdirectories all text files that contain their own name. How do I do this? (preferably without awk command)
2
votes
1answer
25 views

Return count of matches with find/replace using sed

I'm trying to get a count of the number of replaced strings with find and sed. What I'm starting with: # find . -name \*.php -exec sed -i -e "s|finddddd|replaceeeee|g" {} \; This replaces four ...
1
vote
2answers
36 views

find -delete does not delete non-empty directories

$ find ~ -name .DS_Store -ls -delete works on Mac OS X, but $ find ~ -name __pycache__ -type d -ls -delete does not - the directories are found but not deleted. Why? PS. I know I can do $ find ...
0
votes
1answer
43 views

Recursive chmod file and dirs on debian behaves differently to CentOS

Both of these commands run ok on Debian but do not work on CentOS: find . -type f -exec chmod 644 {} ; find . -type d -exec chmod 755 {} ; any idea to solve?
0
votes
2answers
43 views

How to list only filenames removing directories and subdirectories

How can I get the list of only filenames and remove directory and subdirectories using find, sed, awk, cut or any. For e.g : I get list of all media files using find as such: find /var/warehouse/* ...
2
votes
1answer
13 views

How can I use `find` with `-pattern` and also restrict depth?

This is as far as I've gotten: find . -path \*/pages/*/index.css Which will find: ./lib/pages/home/index.css ./lib/pages/home/lib/header/index.css What I really want is to only find: ...
1
vote
1answer
51 views

How to output the directory structure to Json format [duplicate]

I have been using 'find' to output the directory structure from the root down and I don’t mind that it takes a while. My problem is that I want to cut down on the redundant info of repeating every ...
4
votes
3answers
203 views

How do I find a file with a name which depends on the current date (and a random component)?

I have to check a particular path every day and find the file with a name of the form: StaticData_Sets_yyyymmdd-232550.txt The date in the name after the string StaticData_Sets_ is updated every ...
-1
votes
3answers
46 views

Find files less than 1 week old with match TODO in files

My unsuccessful proposal find ./ -newerct '1 week ago' -print | grep TODO No output although should be. Files are text files like Lorem % TODO check this out Lorem ipsun How can you find less ...
9
votes
1answer
356 views

Find a file where name starts with a capital letter

I'm trying to find all files for which there name starts with a capital letter. I have tried using the following command: find . -type f -regex '.*\/[A-Z][^/]*' It's finding paths with only ...
2
votes
1answer
30 views

Confused about piping commands from find to commandX?

I have a script, run.sh, that looks like this: #!/bin/bash FILES=$(find corpus/ -type f) for i in $FILES do ./individual.sh $i done It runs without problem. I want to do away with the run ...
3
votes
1answer
63 views

Find the total disk usage not including files containing a string

I am trying to get the disk usage of the owncloud directory except not including the files and dirs containing the string nobackup in the name/dir. This is my command so far : find . -type f -not ...
2
votes
1answer
26 views

Which types of files can have a shared library dependency?

I'm trying to find a way to let the find command only find files, that could possibly have a shared library dependency (meaning they produce output when called with ldd). To find all dependencies of ...
1
vote
1answer
48 views

How to remove prefix from multiple files in a directory [duplicate]

I have ~250 files with the name: no_responseEvent_2002.02.07.03.15.56.970/ no_responseEvent_2002.02.10.01.47.07.450/ no_responseEvent_2002.02.13.14.18.46.00/ I want to remove ...
0
votes
1answer
26 views

Using find to search and report files that have one but not two keywords inside

I'd like to use find to report files under the following conditions: If the file contains the word "Serializable" Then report the file if it does NOT contain the word "serialVersionUID" Something ...
0
votes
2answers
23 views

what does `find pattern dir` do?

When I search for some files under a dir, I run find dir -name pattern But I find that the following will return all the files under dir, regardless what pattern is: find pattern dir is it just ...
1
vote
3answers
93 views

How to enter foo-* folder without actually using wildcard or shell expansions?

Short story I'm looking for the command to enter first found foo-something directory like: cd foo-* but without using wildcard (or other special shell characters). Long story As part of the ...
5
votes
1answer
104 views

find -maxdepth 0 not returning me any output

I am trying to understand how to use find -maxdepth 0 option. I have the below directory structure. --> file1 --> parent --> child1 --> file1 ...
1
vote
1answer
35 views

How can I run a script recursively in a directory

I am using the following code to decode JPEG-compressed DICOMs. find ./* -maxdepth 0 -name '*.dcm' -printf 'dcmdjpeg %p %p \n' | sh I run this code inside any folder containing those files. The ...
1
vote
1answer
42 views

find files with extended attributes [duplicate]

Can I use find to find all files which have extended attributes set? Let's say, I want to find all files with +i, immutable attribute in /foo and its subfolders. I could not find any, mention of ...
0
votes
1answer
81 views

Extract values from filename and add it into a text file

I have a gridded model data (separated by different depth) saved in text files. The structure is like this: Format of every column in a row in the text file: x_coordinate y_coordinate density ...
1
vote
3answers
62 views

Why does find -inum iterate through the whole filesystem tree?

It surprises me to see find iterate/walk through the complete filesystem when I do a simple find -inum 12345 Without background info it seems to me that there should be much easier ways for to tell ...
8
votes
6answers
435 views

When does the empty string denote the current directory?

In a script I use find to collect some files in the current directory, as in $ find . -name "*.h" ./foo.h Now I'd like it to just output foo.h, without the ./ prefix. I thought that the empty ...
1
vote
1answer
62 views

shell for loop with find with filenames containing spaces [duplicate]

Consider a directory with typical Microsoft Windows filenames: New Document.txt Foo.doc Foo - Copy.doc I'd like to do something on each file such as: for sendfile in $(find ${POLLDIR} -type f ...
0
votes
3answers
19 views

Setting global browsable permissions for subdirectories (r-x) but making files inaccessible to everyone but the owner and group members

I typically have a directory where I want all users to be able to browse through but having files be unreadable and unexecutable. I see some related questions that do not exactly match what I want: ...
5
votes
1answer
211 views

combining find with other commands: when to use -exec and when to use pipe? [duplicate]

I've learned to use the find command by itself to find files and directories however when it comes to doing something with the files/folders I'm confused. Given the following command: find . -type f ...
0
votes
1answer
42 views

find files in folder newer than

I searched through man find but it doesn't give me the answer to a simple task: I want to list all files inside a folder that were modified during the last 5 hours. I tried find ~/.purple/logs ...
1
vote
2answers
54 views

Moving files older than one year to parent archive directory

I want to move the photos of my collection into an "/home/Bruno/Archiv/Bilder" directory, which is parent to the "/home/Bruno/Bilder" Directory. I started of with: find -ctime +365 -exec echo mv ...
0
votes
4answers
65 views

grep for files and open the resultant matches

I'm trying to open all files based on some return values from grep in the command line. I know that I can use the -l option to only return filenames, but I would like to combine this somehow with ...
1
vote
1answer
30 views

Find files belonging to a group

Actually I want to find all the files and folders that are under the same group, for example I have this : [test] user1/sam a.txt user9/sam b.txt user4/sam I'm looking for a command ...
0
votes
2answers
56 views

Find and for loop

Trying to do a mass convert from M4A to OGG in a large music collection, I have: #!/bin/sh for i in `find /home/family/Music -name *.m4a -print0` #do ffmpeg -i "$i" -acodec libvorbis -aq 6 -vn -ac ...
5
votes
1answer
65 views

find directories not containing a file

How can I use the find command to locate directories that do NOT contain a particular file? E.g., if I have bunch of directories that should be under revision control, can I search and find the ones ...
4
votes
1answer
83 views

Problem combining -or and -exec with find command

I'm finding that when I use find's -or operator in combination with -exec, I don't get the result I expect. When searching for .cpp and .h files, the command works as expected if I don't use -exec: ...
1
vote
1answer
25 views

my permission command doesn't work properly

find . a* -exec chmod o+r {} \; find . *d -exec chmod o+x {} \; I want to give o+r to all files that start with "a" and o+x to all files that end with "d", but these lines seem to affect all files ...
1
vote
1answer
39 views

Replace cp function by rsync [duplicate]

I'm trying to replace my cp function by an rsync function My cp function is the following find /home/odroid/USBHD/Movies/ -iname "*.mkv" -mtime '-1' -exec cp -n {} /home/odroid/NASVD/Movies \; do ...
4
votes
3answers
133 views

Finding files on a Unix server and sorting by size

I have a web server where I have run out of space and it's causing issues with the WordPress sites I am running on them. I know that I have a lot of large .png files (the fact that it's PNG is a ...
1
vote
2answers
59 views

run grep cmd recursively and print path name and result

I have a log file that exists in multiple directories one for each client. I am trying to run the following: find . -iname "20140926.log" -exec cat {} \; | grep 123456 | grep 'food="100"' | wc -l ...
1
vote
2answers
27 views

Why does find complain of an invalid expression?

I have shell script like this to copy from backup file to weekly directory: #!/bin/sh find . type f \( -iname "SS1*.tar" -o -iname "SS2*.tar" -o -iname "SS3*.tar" -o -iname "SS4*.tar"\) -exec cp {} ...
0
votes
1answer
71 views

How do I delete directory and file, if .picasa.ini is the only file in the directory?

I want to start from a root directory and recurse through the tree. I want to delete the directory and file if there is only one file in the directory called .picasa.ini It seems like the "find" ...
1
vote
2answers
67 views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
2
votes
2answers
47 views

List of subdirectories that contains a particular file name

I am wondering if i can do this in a single shell command. I am in home directory and want to find a list of subdirectories that contains a particular file. The file name and the depth is always ...
1
vote
2answers
39 views

List folders that contain more than X images

Is there a way to return a list of all folders on a given disk containing more than X images ? The search should be recursive but X should not. Example for X=100 : Folder A |_ folder A1 ...
1
vote
2answers
70 views

finding latest date and date modified file and using sed

I have a series of files that contain a date and I need to get the file which has the latest date, and the latest date modification and pipe it to sed. I have tried various approaches and I cannot ...
0
votes
3answers
143 views

bash find using variable

I have an issue I don't understand. It is simple and it should work, but it doesn't. =EDITED exactly what I can see from terminal= I have a list of filenames: [molni@archlinux picasa_album]$ cat LIST ...
2
votes
1answer
43 views

how to execute a shell built-in if find found certain files

In general, if we want to execute a command if find identifies files corresponding to certain specs, we can use -exec. But in my case I want to exit the shell/script if find found a match and -exec ...
4
votes
5answers
346 views

Clone directory tree structure and copy files to the corresponding directories modified after a specific date

I have a folder with more than 30 sub directories and I want to get the list of the files which was modified after a specified date(say sep 8 which is the real case) and to be copied with the same ...
3
votes
1answer
45 views

List File Space Ownership By User

I have a 4TB NFS file system that is being served from a NetApp filer. The NetApp's quota tools tell me that a certain user is using X amount of disk space in that qtree, but it isn't in "their" ...
9
votes
1answer
328 views

Is it possible to use `find -exec sh -c` safely?

I'm trying to use find to echo 0 into some files, but apparently this only works with sh -c: find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \; But using sh -c with find -exec ...
2
votes
2answers
51 views

Reference a path name in `find` output results

What I would like to do is to be able to reference a find path name result as a parameter to another command without laboriously typing the full path name. Example: $ find -name testfile path1 ...