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

learn more… | top users | synonyms

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
119 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
22 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
274 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
65 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
33 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
16 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
50 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
55 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
52 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
133 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
135 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
36 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
56 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
50 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
52 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
43 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
293 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
62 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
83 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
75 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
74 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
56 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
57 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
62 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
119 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 ...
1
vote
2answers
100 views

find “corrupt” file, nesting an if inside a find command

I'm trying to find "corrupt" files inside a directory structure, namely files which the file command would interpret as "data". Here is the command I've been trying to run, but fails: $ find . -type ...
1
vote
4answers
233 views

Bash command help to “search and replace” file in changing directory tree

The Scenario: I've built a collection of files for research in a central repository on my server. I'm continually curating the repo changing the directory's tree structure by renaming and moving ...
6
votes
4answers
237 views

find: list all directories except those with numbers in their names and their children

I am running the following to find all directories without a number in them (not including the original path): find /path/2/directory -type d -name '[!0-9]*' The problem is that it finds ...
-3
votes
1answer
31 views

List the names of file with a certain permission only in the sub directories

So basically, I want to know how to list only the name of the sub directory that has a certain permission. The command I got so far is this: find */* -maxdepth 2 -perm 770 but this just gives me ...
1
vote
1answer
26 views

Find Source Files for OpenGL on Host

I am a newbie to linux. I just installed openGL on ubuntu and would like to tweak some of its source files I use in order to print certain results of some calculations done. I found the header file ...
0
votes
2answers
78 views

Find command - argument list too long

Oracle Linux 5.10 BASH shell [oracle@src01]$ getconf ARG_MAX 131072 [oracle@srv01]$ ls -1 | wc -l 40496 #!/bin/bash # # delete files in /imr_report_repo that are older than 15-days find /...
-1
votes
2answers
67 views

Finding the number of files in a folder [duplicate]

How can I find a number of files in a folder, assign it to a variable, then echo that variable, all in one command line?
1
vote
2answers
53 views

How to allow spaces in directories when using find -exec together with basename?

I'm trying to find all the directories in a given path, and create soft links inside those directories into directories with the same names at another location. Many of the directories have spaces in ...
2
votes
3answers
189 views

Find and rename files (including directories) whose filenames contain space [duplicate]

I have quite a number of files and directories with spaces in their filenames in my ext4 filesystems. How should I safely find and rename them? I have bash and am running Ubuntu. Is it possible ...
3
votes
2answers
44 views

Using literal empty curly braces {} inside sed command from find -exec

I'm wondering if it is possible to include empty curly braces {} inside a sed replacement called from a find -exec. An example: find "$dir" -type f -name "*" -exec sed -i s/hello{}a/hello{}b/g '{}' +...