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

learn more… | top users | synonyms

1
vote
3answers
41 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
34 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
221 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
33 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
34 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
33 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
35 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
34 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
70 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
710 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
0answers
18 views

Issue in file transfering [closed]

I have a issue in transferring files from my local server to my head office server which is in Sweden. Usually we transfer the files which is in PDF format. When I use my normal transfer(copying files ...
0
votes
1answer
51 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
38 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
52 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
75 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
47 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
45 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
154 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
48 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
88 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
135 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
37 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
204 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
45 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
82 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
131 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
37 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
69 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
45 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
514 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
89 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
60 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
103 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
26 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 ...
1
vote
2answers
29 views

Rsync “finds” files that are implicitly excluded

I have a semi-working rsynccommand that I have combined with the find command on a linux box to do a simple file transfer of a specific type and date. Here's the command: rsync -avx --timeout=30 ...
0
votes
1answer
20 views

How would I find any symlinks on my system that reference “/tmp”?

I need to create a list of all symlinks that reference the /tmp directory. How many are there in total?
0
votes
0answers
29 views

Is there a `find` command that uses a database, like `locate`?

locate is simple yet quick because it's database based. find offers much more options but it's slower because it actually browses the filesystem each time it's invoked. So.. find using a database ...
3
votes
3answers
44 views

Find command: multiple conditions

As a standard for my file/dir naming I use something like putting date and tags string into the file name separated by underscore, eg: 2015_03_10_usa_nyc_vacations_album_pictures For a long time I ...
2
votes
1answer
46 views

Push onto array with find exec

I want to iterate over all the files found by find and add each one to an array. Here's what I have so far: myarray=() find . -name '*.php' -exec myarray\+=\({}\) \; echo "${myarray[@]}" Instead, ...
1
vote
1answer
49 views

Find all the modified svn files and copy files modified in the same folder structure

I get all the modified svn files using svn st | grep ^M command M student/includes/class_student_promotion.php M student/includes/class_student_report.php M ...