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

learn more… | top users | synonyms

0
votes
1answer
18 views

Can't find the location of DUMPed file system

I dumped a file system, chose the name for the dump ("home_fs_dump"), the dump was declared successfull, and yet I couldn't locate this name anywhere in the system. (And at the end I tested if locate ...
1
vote
1answer
21 views

Unzip specific files from multiple zip files

I'm new to Unix and am trying to extract specific pattern filename from the multiple zip files. I'm using find to find the zip files, and then trying to extract files having the filename CTL in the ...
2
votes
1answer
36 views

make find fail when nothing was found

When find is invoked to find nothing, it still exits with code 0. Is there a way to make it return an exit code indicating failure when no file was found?
3
votes
1answer
22 views

Does find -links count the hard links or symbolic links?

Does find -links count the hard links or symbolic links ? find -links 2
11
votes
6answers
990 views

What is the difference between find . and find . -print

What is the difference between: find . and find . -print What does -print actually do? $ find . . ./hello.txt ./hello ./hello/txt ./hello/hello2 ./hello/hello2/hello3 ./hello/hello2/hello3/txt ...
0
votes
5answers
45 views

Difference between 'ls -ltr abc*' and 'find ./ -name abc*' command? [duplicate]

To search a file in a directory, I found two commands as below: ls -ltr initialfilename* find ./ -name initialfilename* Sometime, first command gives me the search result but sometime I used to ...
0
votes
1answer
24 views

find returns weird file order on RHEL but not on OSX [duplicate]

When I enter find . -iname "[0-9]*.nii" on my OSX machine it returns: ./03_Rest_fcMRI/9793_01_03_1.nii ./04_VEMP/9793_01_04_1.nii ./04_VEMP/9793_01_04_2.nii ./05_Tapping/9793_01_05_1.nii ...
1
vote
3answers
54 views

How do I create a copy of a file in multiple directories?

I have a folder structure conf/ widget1/ env1.cfg env2.cfg widget2/ env1.cfg env2.cfg widget3/ env1.cfg env2.cfg widget4/ ...
3
votes
1answer
35 views

`find` multiple -o -name condition AND ! -name

I'd been playing with this snippet and seems like I can't make my desired find work. I tried google but all tutorials does not seem to tackle this scenario suppose i have the following files ...
5
votes
4answers
237 views

Converting `for file in` to `find` so that my script can apply recursively

I've been working on my first bash script for some time now (I just started UNIX this week). I have this idea of running a bash script to check some conditions and using ffmpeg to convert all the ...
0
votes
1answer
38 views

find all directories (except `encoded`) in the working dir then delete all of them

I am trying to test this scenario, I have these files /encoded encode <~~~ a bash script /dir1 /dir2 .../dir2-sub test.meta what I wish is, for find to search for all directories in our current ...
0
votes
1answer
38 views

Why does “find / -path '/a/b/c” scan the whole / (root)?

Why does find / -path '/absolute/path/to/some*file' scan the whole root (/), including files in /proc, /bin and others? I usually get these errors: find: `/proc/tty/driver': Permission denied find: ...
2
votes
1answer
34 views

Skipping pseudo-filesystems when doing find/exec

Let me be clear about this. I want to do a find over multiple filesystems. What I wish to do is skip pseudo-filesystems. Other than -prune, is there a way to do this?
4
votes
1answer
38 views

Find the files between two folder dates in linux?

I need to find the folder names along with the file names which has my string in their contents. I am in this directory "/data/queue/data" and I have lot of folders in the same directory and inside ...
1
vote
1answer
35 views

List all regular files containing (in their name, directory or their content) a specific (sub)string

Like in the title, and also I want to print the number of the line in each (text) file where the substring occurs. So far I have: find /sys | grep "filesystem" But it appears to only look at the ...
2
votes
3answers
77 views

bash: error handling on find -exec

I was using this little script to find malformed images: find -name '*.jpg' -exec identify -format "%f\n" {} \; 2>errors.txt It worked well enough, but now I need to modify it slightly. Instead ...
28
votes
2answers
778 views

find(1): how is the star wildcard implemented for it to fail on some filenames?

In a file system where filenames are in UTF-8, I have a file with a faulty name; it is displayed as: D�sinstaller, actual name according to zsh: D$'\351'sinstaller, Latin1 for Désinstaller, itself a ...
0
votes
1answer
54 views

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
0
votes
0answers
11 views

Result of find in multiple columns [duplicate]

I frequently use find and often the results scroll up the screen while a sizable portion of screen is unused. Is it possible to get the results of find in two or more columns, similar to those of ...
1
vote
1answer
41 views

Find only in directories n levels deep

I use this command to find and run all istances of wp-cron.php I have for each site I have: find /var/www/ -name 'wp-cron.php' -exec php -q "{}" \; Since my websites tree is: ...
2
votes
1answer
58 views

Using find and sed to copy 20th line of many files into one file

I have a folder called "PKA1" Within this folder I have several folders that look as: 1eV, 2eV .... 30eV Within each of these I have subfolders I have a file called PKA.dump I want to copy the ...
0
votes
2answers
78 views

Recursively remove files with idx > 10,000

The problem In the current working directory I have several (very many) folders and some of them have lots (like 100,000+) of files inside. My goal is getting just the folder with 10,000+ files and ...
3
votes
3answers
49 views

Use for loop in find exec

-> find .. -name bin -exec for file in {}/* ; do echo $file ; done \; -bash: syntax error near unexpected token `do' What is the proper syntax for this command ?
1
vote
2answers
54 views

grep or find a pattern in all directories [duplicate]

I have an account number 1234-5678, I am trying to find it in all files of directories. I used the below command but no result found. grep "1234-5678" */ Please can someone help me how to find it in ...
2
votes
2answers
40 views

Is there `find`'s `-exec` like option in `ack-grep`?

I want to remove all texts that include string foo. I can list all files by ack-grep foo, but I couldn't find a way to remove all files like -exec rm {} option like find. How can I delete all files ...
1
vote
1answer
24 views

How to exclude the folders proc and sys from search with find command ?

I wanted to execute a script that picks out a random directory path: find / -type d | shuf -n1 Unfortunately I get error messages about the prohibition of entering certain directories. How can I ...
1
vote
1answer
37 views

How to interactively remove all directories matching given criteria?

My script below has two problems: The script stops after first matched directory rm -i is not quite interactive What are my incorrect assumptions that make it fail? How can I fix it? ls -1A | ...
0
votes
2answers
38 views

Rsyncing files from server to local machine automatically

I currently have a crontab job running on my machine every friday at 3 AM as a back up method. The job runs a bash script which runs an rsync command to sync files from the server to my external hard ...
-1
votes
1answer
23 views

Copy files from find command [closed]

I am trying to copy all *file.log files found using find. The problem is all files are named the same and it is only copying over one file. I need to find a way to rename the files in the command or ...
5
votes
2answers
157 views

How can I list files of which no symlinks exist?

I have a large "myfiles"directory full of miscellanous documents and do not want to modify its structure. I therefore created (several) other directories for each class of documents. For example I ...
1
vote
2answers
49 views

How to list only the last line of each directory?

I learned thanks to you, how to display only the last line of a listing,e.g. ls -ltr | sed '$!d' Now I thought, how to combine it with the find command, in order to repeat this onto each directory ...
5
votes
6answers
90 views

Exclude directories in locate search

A search with locate finds paths in the filesystem. Often, you know a priori you are interested in either files only, or directories only. A 'locate' search often returns many results. It would be ...
2
votes
3answers
136 views

find and grep pipeline returning nothing

I have files named lect1.txt, lect2.doc, and lect3.doc. I want to get a file which is a .txt file, and contains lect as the filename. I tried find *.txt | grep lect* and it returned nothing. ...
1
vote
0answers
39 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. ...
0
votes
1answer
225 views

How to find all JPG files on the file system when .jpg extension is not obligatory ? [duplicate]

First thing I noticed when switched from Windows to Linux was, that Linux has no strict naming convention and no obligatory file name extensions like .bmp, .jpg, .exe etc. Therefore I can not tell by ...
0
votes
1answer
47 views

Search a file for a string in multiple directories

Can someone please help me with a command to search a file for a string in multiple directories? I am searching for the VIP in httpd.conf in multiple httpd instances. I am using: find ./ -name ...
1
vote
3answers
85 views

Find result used in if statement

How can I use the result of a find command in an if statement and compare with true or false? Something like this: if [ `find . -name test.txt -size 156c`="true" ]; then echo Found; fi This is ...
0
votes
1answer
12 views

Makes it a difference whether I use a different -n flag value for xargs in combination with find command ?

Assume, someone searches for files that match some criteria using the find command and pipes the result into the rm command. find / -type f -name "*.jpg" | xargs rm First, I am not sure if the ...
2
votes
3answers
21 views

list all symbolic links to valid directories only with find

I can use find /search/location -type l to list all symbolic links inside /search/location. How do I limit the output of find to symbolic links that refer to a valid directory, and exclude both, ...
2
votes
4answers
138 views

How do I perform xargs grep on grep output that has spaces?

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
1
vote
1answer
38 views

mv to file with

I ran the following mv command, apparently by mistake using backslashes by mistake instead of slashes. mv 2015-02-02_flyer_ppces.pdf ..\PPCES2015\2015-02-02_flyer_ppces.pdf The output is empty. ...
0
votes
2answers
27 views

Find a file and execute a command in the file's directory

I am trying to use find so it would find a script file and if found execute it in the same directory it found it in. Something like this: find . -name "CLEAN" -execdir "CLEAN" {} \; except {} is ...
1
vote
2answers
39 views

find files with path of a directory exclude subdirectories

How can I use find to traverse a directory, but not recurse into its subdirectories? I tried -prune and it does not work. And there is no -maxdepth option. find /opt/projectname/bin -type f ...
2
votes
4answers
70 views

Find and move with exclude

I need to use find and mv together requirement : Need to find all file *.xml but exclude deposit.xml and move it to another folder ( fairly simple) My attempt : mv `find ./*.xml '!' -type d | ...
2
votes
2answers
47 views

SED on Mac OS X

I'm using a MacBook Pro and I want to find and replace a given word with another with sed command, but it makes no changes. What is the problem? sed 's/\<cat\>/dog/g' tt.txt
6
votes
4answers
523 views

Can I use Find and Grep in one line

I am a complete novice in UNIX and desperately need some help. I have a directory structure based on events. In these events I have one type of file which does or does not contain a pattern for ...
1
vote
1answer
96 views

How to delete remaining files of removed user?

I know deleting user with userdel username can cause information leakage and other security issues (as tutorial book says, administrator should delete user with -r option). But i tried it to see what ...
2
votes
1answer
61 views

How to merge these commands into one?

This is what I am wanting to do: Convert a folder of HTML files into markdown, also copying over the the xml metadata of each of the HTML files by converting into YAML. I have done research and come ...
2
votes
2answers
105 views

Run a command with wildcards in each subdirectory

I use this command to make a montage of all the images in a directory: gmic *jpg -gimp_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0 -o -0000."$(date)".jpg I want to run this ...
0
votes
1answer
27 views

Find a file that doesn't include specific characters

I want to find a specific file that doesn't start with a,k,G or Q and in which the third letter in the name is not a digit. I have tried many links, but found nothing regarding to this composite ...