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

learn more… | top users | synonyms

0
votes
1answer
15 views

Issue finding lines using grep in UNIX

I am trying to use a .txt file with around 5000 patterns (spaced with a line) to search through another file of 18000 lines for any matches. So far I've tried every form of grep and awk I can find on ...
3
votes
3answers
78 views

what's the difference between using 'single quotes' or not in find command

find ~/ -name *test.txt find ~/ -name '*test.txt' Can anyone help me to construct an example where the first form fails but the second still works. And tell me the difference between them.Thanks!
1
vote
0answers
23 views

trash and restore script - issue restoring

#!/bin/bash echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)" read ans case "$ans" in Yes) echo "$(readlink -f $1)" >> "$HOME/TrashLog" && mv "$1" ...
0
votes
1answer
27 views

What does newermt mean in find command?

I know I can use this option to find file between particular modified times. But I'm curious about what does this mean? I used man find | grep newermt trying to find something. But I got no direct ...
0
votes
2answers
46 views

How to find a file in Unix using find command?

I have been trying to search for a file which contains a specific pattern. The pattern is itself in a variable tmpfl echo $tmpfl --> ack_2* Now to find for the file in the current working ...
1
vote
2answers
65 views

Sort files according to their extensions

I have made a script that will sort files according to their extension and place them in the proper folder. For example, place abc.jpg in the directory jpg. #!/bin/bash #this script sorts files ...
3
votes
5answers
75 views

How to show distinct directories on find?

I want to find all directories containing, for example, files named *.txt. but the output must not contain duplicates. How to do it?
-1
votes
3answers
37 views

How to print the base file name using find in Unix?

I have been trying to print out the base file names using find in Unix. To simply print out the file names the command I have been using is this find . -type f -name \*.out -print It prints out ...
1
vote
2answers
44 views

Find files that end with number

Im trying to make some backup script as the log files get bigger and bigger. What i have is coping the current file, (for example secure file in /var/log/) and remove the content from that file. But ...
2
votes
3answers
50 views

Remove files from listing that are created/modified on Saturday

I am not sure if it is possible. I do ls -l, it gives all the files in the current directory. Is there a way to say list only files that weren't created/modified on Saturday's with shell command?
2
votes
1answer
26 views

Problems with find, xargs and egrep

I this is what I what I'm trying to end up with (except working) find ./ -mindepth 1 -type f -mtime +60 -print0 | xargs -0 egrep -vZ 'vvv|iii' What am I doing wrong? $ ll total 0 -rw-rw-r-- 1 ...
1
vote
1answer
30 views

Using double or no quotes with wildcards

I came across this article which attempts to explain the find command.It gives an example of find /tmp -iname "data*.txt" now this article here states that Double quotes do not suppress the ...
1
vote
2answers
56 views

Seaching a File in Unix for a given string and then another set of Strings within this file and print file properties too

I am using command to search for files staring from a given Directory in Unix , files ending *.sas and containing the string DB2. I then inturn want to search the resultant set of files for the ...
0
votes
1answer
24 views

regexp in find to locate only

I have csv file (products.csv) with product numbers $ cat products.csv | head -3 2.20 2.21 2.22 in another directory I have thousands of product images in subdirectories. I need to locate product ...
1
vote
1answer
53 views

What does `{\} {}` mean in `find` command?

Please explain this command in detail. I am using this command to find large files above 6MB and split in to 5MB chunks in the same folder. Then it removes the original files (larger than 6MB) in the ...
0
votes
1answer
41 views

find - exec rm vs -delete

I'm trying to understand the difference between these two commands: sudo find / -name .DS_Store -delete and sudo find / -name ".DS_Store" -exec rm {} \; I noticed that the execmethod is ...
0
votes
4answers
41 views

Print only directories with more than 31 files

I am using this script to count files on my directory and sub-directories: for i in $(find . -type d) ; do printf "$i %s\t" ; ( find $i -type f | wc -l ) ; done This script works fine. What I ...
0
votes
1answer
20 views

Query for displaying UNIX files created on particular timestamp

I wish to list down all files which were created on particular time. (For ex: files created on time: Nov 13 09:09) -rw-r--r-- 1 bitt1 cerillio 43268 Nov 13 09:02 sendEsbUpdateEvents.log ...
3
votes
4answers
191 views

what is the difference between `find .` and /home/user/* as an input to for command

What is the difference between find . and /home/user/* as an input to for command.? For example: for var in $(find .) do echo "$var" done or for var in /home/user/* do echo "$var" done In the ...
1
vote
2answers
88 views

Search 2nd line of files and print filenames to stdout

I have a few directories of ~10,000 files. What's the quickest way to search each file and return the filename if the second line contains a specific string? Edited for clarity
1
vote
1answer
30 views

Different results OS X/Linux with “find PATH -mount \( -type f -o -type d \) -print0 | LC_ALL=C sort --zero-terminated > OUTPUT.txt”

this command is part of a script I use for comparing files: find test/ -mount \( -type f -o -type d \) -print0 \ | LC_ALL=C sort --zero-terminated > OUTPUT.txt // test/ is the PATH ...
1
vote
2answers
40 views

how to I change permissions to all subdirectories except for 1 folder using a single find command?

I need to change the folder and file permissions in all subfolders except for 1 folder. Currently, I'm running several find/exec commands to make it work. e.g. find /mystuff/temp/videos -type d -exec ...
2
votes
2answers
48 views

How to pipe a the output of find to another find invocation

Here's what I'm trying to do find . -maxdepth 1 -type d -print0 | xargs -0 -P4 find -name 'war' -type d I would like to create a list of directory names, null-terminated, and then pass this list to ...
2
votes
1answer
27 views

How to find only files, with which command xyz ends successfully?

I'm trying to find all files, that make a given command end successfully (exit code 0). The find man page says about -exec: Execute command; true if 0 status is returned. Although listed under ...
2
votes
1answer
131 views

Shell script, find -name, and wildcard expansion

I'm trying to use find -name in a sh script with a previously computed complex argument for the condition. Simplified, it goes like cond="-name '*.txt*" find . $cond -ls But now I have the problem ...
1
vote
3answers
50 views

Print full pathname with `ls` and `find`

I want ls to print with absolute pathnames, how do I do that? find / -type d -mount -exec ls -ls {} \; ls is printing only the relative file names within the directory.
1
vote
1answer
31 views

Find a file with a naming pattern [duplicate]

I have a file in a particular location. The file name is in format StaticData_Sets_yyyymmdd-hh:mm:ss.txt This file is generated everyday with current date and timestamp.The string StaticData_Sets_ ...
1
vote
5answers
58 views

How to delete files, symbolic in one folder, but leave its subdirectories unchanged?

Assume there is a folder that has files, symbolic links, and subdirectories as following: files: file1, file2, file3, file4 symbolic links: link1-->file2, link2-->file3 subdirectories: dir1, ...
2
votes
2answers
42 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
360 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
38 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
52 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
56 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
52 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
14 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
83 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 ...
3
votes
3answers
216 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
63 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
397 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
31 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
76 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
32 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
53 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
29 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
98 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
135 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
40 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
60 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
89 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 ...