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

learn more… | top users | synonyms

1
vote
2answers
68 views

Read files from directory and organize them by extentsion into corresponding folders

I'm trying to create a bash function script that will allow me to create multiple directories with the names below. I'm also trying to organize files by extension into their corresponding folders (i.e....
1
vote
3answers
55 views

Is there a faster way to find specific files than using find?

I have to find in a folder the files not having certain permissions (755). The sub-directory has other sub-directories containing in total millions of files, and the find ./ -not -perm 755 command it ...
1
vote
1answer
48 views

Why does `find -size -1G` not find any files?

When I issue: find / \( -type f -size +10M \) -and \( -type f -size -1G \) I don't receive any results; however, when I type: find / \( -type f -size +10M \) -and \( -type f -size -1000M \) ...
1
vote
2answers
55 views

find all hard linked files between two directories

How do I find if any files among two or more directories are hard linked? In other words, do any files under two or more directories refer to the same file? Similar to How to find all hard links to ...
0
votes
1answer
62 views

Why does 'find -mtime +1' include today's files when used in a script? [closed]

I'm using the following find command in a script: find . -type f -mtime +1 When I use it from an interactive shell, this gives only old files, but in the script it also gives today's files. Why? ...
3
votes
1answer
63 views

Limit POSIX find to specific depth?

I noticed recently that POSIX specifications for find do not include the -maxdepth primary. For those unfamiliar with it, the purpose of the -maxdepth primary is to restrict how many levels deep find ...
0
votes
3answers
1k views

find -exec ls -lR {} \; returns every item twice

Background: I'm currently writing an archiving script, which creates gzipped tarballs from some folders and their contents. It should be able to synchronize the gzipped archives with the sources ...
0
votes
2answers
33 views

Create a list of files in a directory with a certain char

I would like to be able to list all files within a folder which have a certain character as the third character. For each file, I then want to be able to perform an action, maybe delete or move. I'...
1
vote
1answer
29 views

Remove certain types of files except in a folder

I have a command in my makefile for clean: rm -rf */*.o */*.cmo */*.cmi */*.cmx */*.cma */*.cmxa */*.annot Now I would like to write a cleanpartial that removes these files except those in the ...
3
votes
2answers
94 views

execute command from find called by find

Is there a way to call find recursively? I would like to search for files matching a given pattern only in directories matching another pattern. Basically: for each (sub)directory D matching "*....
1
vote
1answer
32 views

Substitute with `…` multiline output of find command [duplicate]

I need to substitute output of find command to another command to process every found file, e.g.: mdls `find ~/target_dir/ -iname '*some*' -depth 1` (mdls is a command in OS X which get metadata ...
3
votes
2answers
123 views

Filter files generated by `find` by parsed output of `file` command

I'm writing a quick tool to inspect the contents of a node.js node_modules folder or python virtualenv for native dependencies. As a quick first approximation to this I wrote the following command. ...
1
vote
0answers
17 views

Find and redirect to capture pattern filename

I'm looking a way to do something like: find /path -name "201[2-6]*" | awk -F"/" '{print $5"/"$6"/"$7"/"$8",0,0,0"}' > archives_201\1.csv where archives_201\1.csv could be archives_201[2-6].csv ...
0
votes
1answer
23 views

Why find is not finding some folders with spaces?

find -name "* *" -type d | rename 's/ /_/g' For instance, 'Paired End' folder name on this path is not being replaced with spaces: /home/bernardo/Raw_data/Raw_data_M6_and_V2_UIC_April_2014/...
10
votes
2answers
275 views

What are the security issues and race conditions in using `find -exec`?

From the find man page: -exec command ; There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead. -execdir command {} + ...
1
vote
2answers
67 views

Tar files starting with the same pattern

I have some log files named : 2016-02-10_03-52.log 2016-02-10_04-43.log 2016-02-10_02-13.log ... 2016-03-15_07-03.log 2016-03-15_09-08.log Basically the pattern is : YYYY-MM-DD_.log I would ...
0
votes
0answers
37 views

find and copy files change the modified date to 1980-1-1

I use command to find and copy files in cygwin in windows . My command is find -name '*.docx' -exec cp -p -t /word {} + however , when the files is copied to destination folder, I can see the ...
0
votes
0answers
17 views

Different regex engines and syntax in unix tools like grep, find, vim, sed, aptitude etc [duplicate]

I would like to learn and use regex more. I made couple tutorials and trying use regex in everyday tasks. But I've found thing that demotivates me and slowing learning process - different syntax/...
0
votes
2answers
42 views

/usr/bin/find invocation doesn't work when used with command substitution [duplicate]

In a script, I have: CMD='/usr/bin/find /etc -type f -exec /usr/bin/md5sum {} \; ' MD5=$("${CMD}") But the script gives the error: -bash: /usr/bin/find /etc -type f -exec /usr/bin/md5sum {} \; : ...
-1
votes
1answer
53 views

how to find and replace a string containing “/” [duplicate]

I am very new to linux. currently I have faced a problem in changing a string in a file which have / character . I want to replace 1/0 with hetero in a file. can you please tell me which command to ...
-3
votes
2answers
56 views

Find and replace in Linux [closed]

I want to replace 0/1 with hetero but whenever I am trying to use the known commands it is showing syntax error because the / is aleady part of the command .. Can anyone suggest a command to solve ...
1
vote
1answer
44 views

Executing shell script from command line [duplicate]

I have a perl script that converts a file to json format and writes the output to a separate directory. It accepts 2 parameters, filename and output directory. The script needs to be run on multiple ...
1
vote
3answers
55 views

How to find an ssh session a process was started from

How can I find a process which was started from some ssh session. For instance, I gave same ssh cridentials (aka. userzxc/passwordzxc) for my several friends which IPs i already know. My goal is to ...
0
votes
2answers
146 views

bash error find: -printf: unknown primary or operator

I make a list of all files in my PC. FILES=$(find . -type f -name '*' -printf "%s/%f\n" | sort -n) The output should be: "size/file_name" 56872/file.txt 98566/test 1000254/foo My PC give me ...
1
vote
1answer
29 views

bash - isolating uppercase words

So, I have a directory containing around 50 directories having for name 3 letter uppercase words: AXC BCC EFC amongst other directories. I have already done a find to seek these 3 letter directories ...
0
votes
3answers
151 views

Remove all special characters recursively from filename [duplicate]

I have multiple files in directories and subdirectories that have special characters not supported by Microsoft file shares and SharePoint. The types of characters run the gamut from tildes to ...
1
vote
1answer
41 views

Error with find when using -newerct values stored in variables

I'm trying to create a bash function that will use a simple file such as sample.txt start=22 Mar 2016 10:00 end=22 Mar 2016 12:09 ...and find files that I have installed to /usr/local within the ...
0
votes
2answers
23 views

Why doesn't `find` find these files [duplicate]

Consider: $ find . -name *.css ./style.css ./view/css/style.css $ ls view/css/ consultation.css jquery.scombobox.min.css page-content.css style.css Why might find have missed the files in view/...
0
votes
2answers
61 views

hp-ux find command not working on a list of files

We're using the following hp-ux configuration: HP-UX dxp10hxw B.11.23 U 9000/800 1446354274 unlimited-user license And trying to run a simple find command as follows: find . ! -type l -perm -0020 -...
1
vote
2answers
51 views

Why does Solaris 10 find / -exec sh -c “echo {}” \; print “{}” instead of filenames?

I do not generally use Solaris, but today I need to craft a find command to execute an operation on identified files using the shell. I am finding that the {} characters are not getting substituted ...
2
votes
1answer
55 views

Convert order for find … -exec

I want to rename files and directories. Let's suppose that I want to convert every ä to a, and I have Järjestelmä/Säätimet. So I say something like find -exec rename 's/ä/a/g'. Now find will convert ...
0
votes
1answer
31 views

Does find Command Do Match For Regexp Because Of Implementation?

In this case discussed: find (GNU findutils) 4.5.11 grep (GNU grep) 2.20 Let's say I have a directory that contains a bunch of files. I want to find the files named jtobdops02.key and jtobdops.02.cer....
3
votes
1answer
44 views

Sorting Directories and Files

I want to use find and sort the response. I assumed that a simple pipe find ... | sort would do it, but the sorting behaviour is weird. For simplicity a simple text file: asdf/2/22 asdf/2/01 asdf/20/...
0
votes
2answers
70 views

If filename has more than n characters, delete the last ones

I'm kinda new with the unix shell, and I don't seem to find the answer of my problem : I have a folder containing multiple files : a correct filename contains exactly 13 characters (numbers + letters ...
-1
votes
1answer
40 views

Searching for most recent file (Display Unique)

If i have a Folder structure with 10 Sub dirs Each sub folder has the possibility to hold a version of a file (Older or newer) "Poor folder structure." I was looking to use Find to locate all files ...
5
votes
4answers
296 views

how to delete all files with specific extension in specific named folders in large tree?

I have large tree, with many pdf files in it. I want to delete the pdf files in this tree, but only those pdf files in sub folders named rules/ There are other type of files inside rules/. The rules/ ...
0
votes
3answers
63 views

Find and replace with filename

I have a large number of files which contain text. All files contain the word "replace" (no quotes). I would like to replace that word with the name of the file. Example, filename is: On Time.txt ...
2
votes
1answer
85 views

Different output of `find | xargs ls` for the same command on different Ubuntu versions

I have two Ubuntu installations: A: 14.04.3 LTS (GNU/Linux 3.13.0-77-generic x86_64) B: 14.04.2 LTS (GNU/Linux 3.13.0-61-generic x86_64) I'm running the following command: find . -name "nosuch....
3
votes
1answer
69 views

Remove files with match only from some subdirectories

I have a directory with several subdirectories; in each of these, I have some files. I want to perform a grep only for some subdirectories to find those files that match the query and remove them; ...
1
vote
2answers
76 views

how to delete (or keep) certain file extensions using busybox find?

I have a folder which contains files (various file extensions) and subfolders. I want to keep certain file extensions and delete the rest. e.g. keep all .txt and .jpg files and delete all other files....
0
votes
1answer
38 views

Order of arguments to find

0:root@SERVER:/tmp # find /tmp/foo* -mtime +74 -ls | wc -l 1330 0:root@SERVER:/tmp # find /tmp/foo* -ls -mtime +74 | wc -l 1750 0:root@SERVER:/tmp # oslevel -s 6100-09-04-1441 0:root@SERVER:/...
1
vote
1answer
128 views

How to find files and act on them (find + exec)

I have downloaded about 3200 websites to the depth 2. So now I have one master folder (abc) that contains many folders, containing files for each website. So my folder abc contains 3200 folders and ...
1
vote
0answers
38 views

Copy file into all subdirectories that contains a file with certain name

I am trying to copy a features[30,55].R script from my desktop into all the subdirectories that contain a file whose name is DONE. I tried the following command: find . -name "DONE" -exec sh 'cp /...
0
votes
2answers
79 views

Find and replace words in text file recursively

I have tree of folders inside these folders there are many text files. These files have the same name "log.txt" and the same format. For example inside every file we can see multiple lines like: date ...
0
votes
2answers
57 views

Find all folders starting with number range

How can I find all folders starting with a value in the number range 500 to 899? I just need to list them in a file. Additional informations: Maxdepth 2 Examples of folder names: ...
1
vote
2answers
58 views

Using Grep Command Without Specifying a Certain Directory [closed]

Can you use the grep command without specifying a directory path afterwards? Example: $ sudo grep "filename" / I have also tried this: sudo find / -type f grep -l "filename" Still no luck. ...
0
votes
2answers
25 views

find a directories that does not contain a file with name OSZICAR and then cd into that directory and do something more

I would like to find directories that does not contain a file with name OSZICAR and then cd into that directory and do something more... all i have now is: find `pwd` -mindepth 2 -maxdepth 2 -type d ...
2
votes
1answer
97 views

Why is this find command not returning filenames containing non-ASCII characters only?

I'm trying to determine the root cause of why this find command is not working; it shouldn't match the file called this_should_not_match below: $ > find . -type f -name "*[^ -~]*" ./__º╚t ./...
1
vote
3answers
63 views

Pipe pattern input to find command

I have a scenario where I am trying to find multiple files based on the output of another command. The command itself is ./libopt -d test . 2>&1 | sed -rn 's/Cannot find library \"(.*?)\"/\1/...
1
vote
1answer
125 views

Find tar.gz files in a folder which are older than 20 days and delete

I have a backup script which creates a backup (in tar.gz) of my /var/www-folder in my CIFS-mount-folder. To delete old backups which just waste memory I have created a cronjob that checks every day ...