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

learn more… | top users | synonyms

2
votes
1answer
92 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
55 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
vote
1answer
79 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
77 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
228 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
227 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
30 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
63 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
60 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
50 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
173 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
41 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 '{}' ...
1
vote
2answers
102 views

List files in current directory, prefix numerically

I'm trying to learn bash and I'm trying to list the files I have in a folder using a bash script from a.sh, like this: 1: a.sh 2: b.sh 3: c.sh I've looked at ls and find commands, but they don't ...
1
vote
2answers
92 views

Renaming Files and Directories Recursively using rename/find

I started learning linux on vmware using centos 7. I created an image directory and several layers of files and sub-directories in that folder. most of the names containing spaces. I want to use a ...
0
votes
1answer
54 views

find comand with -exec ls produces a different output

I am trying to determine which files will be touched based on their modified date. My directory is a top a list of perhaps several levels of subdirectories. From a terminal window I run this command: ...
0
votes
2answers
40 views

How to list only directories that are not on a `.git` directory subpath?

I want to list only the directories that are not inside a .git/ directory on my current path. I'm trying this: find . -path "**/.git" -prune -o -print -type d The .git dirs are excluded, but the ...
-1
votes
3answers
44 views

Find files with the exception list of file name in separate file

I have 10 files in a directory.. test1.txt test2.txt test3.txt . . test10.txt Also a exclude file names exclude.txt which have the below file names test1.txt test2.txt test3.txt text4.txt I need ...
3
votes
2answers
116 views

How is it that the same find command can give two different results?

This has happened to me twice (EDIT: many times and I can replicate it) now. I'm working on a Raspberry Pi, looking for a file I already know exists and so I type this command: sudo find / -iname ...
1
vote
0answers
183 views

rsync only files newer than given date, with --delete

I'm trying to use rsync to backup only the files that have been created or changed after a certain date. The reason is that on that date, the whole system has been backed up. However, those global ...
4
votes
2answers
88 views

confusing about double quoting

I learned when I use command, double quoting treat all things as character except $, `, \ . But, when use command like find -type f -name "*.jpg" *.jpg is inside double quotes. Then, it means we want ...
1
vote
2answers
49 views

To find the size of some group of files

I was trying to find out the total size of all files which are owned by a particular user. While trying so, i get different sizes when executing different commands. Which command is correct to find ...
0
votes
2answers
33 views

Counting the occurences of character in a filesystem tree

The task was to find the number of occurrences of character 'a' in all files in the directory (recursively). My script was this find . -type f -exec grep -o 'a' {} \; 2>/dev/null | wc -l but it ...
2
votes
2answers
76 views

Bash: pipe 'find' output into 'readarray'

I'm trying to search for files using find, and put those files into a Bash array so that I can do other operations on them (e.g. ls or grep them). But I can't figure out why readarray isn't reading ...
3
votes
7answers
174 views

Find directories excluding ending bracket ')'

I'm trying to list all video directories (not files) which don't end in a year e.g. (2015) and more specifically which don't have a year listed, therefore don't end in a closing bracket ). How can I ...
0
votes
1answer
35 views

Using xargs to construct a find command that excludes a list of directories from an environment variable

I know how to exclude certain directories from find: find <path> ! -path <path to exclude>. But this can be too tedious to type out when I need to exclude a lot of directories or simply ...
3
votes
4answers
224 views

How to escape shell metacharacters automatically with `find` command?

I've got a bunch of XML files under a directory tree which I would like to move to corresponding folders with the same name within that same directory tree. Here is sample structure (in shell): ...
0
votes
2answers
54 views

Print the files that find acts on

I use the following command in order to delete only the files that start with DBG and older then two day , but this syntax not print the files that deleted find /tmp -type f -mtime +2 -name "DBG*" ...
1
vote
2answers
42 views

find a file and truncate it

I'm simply trying to find a single log file and truncate it. Why won't this work? find ${listener}/tracefiles/${listener}.log -exec cp /dev/null '{}'\; This returns an error: find: missing ...
-1
votes
2answers
37 views

backup files that older then 3 day

how to move files that start as: DRR_O_sql. and that older then 3 days to other directory as /home/backup example DRR_O_sql.35435 DRR_O_sql.4534534 DRR_O_sql.54232 DRR_O_sql.4.efdedwe
1
vote
1answer
19 views

How can I find .git repositories and pull'em all?

I tried. $ find . -name .git -type d -execdir git pull {}; find: The relative path ‘%ANDROID_HOME%/tools’ is included in the PATH environment variable, which is insecure in combination with the ...
0
votes
2answers
38 views

Where does the find command look first if there are directories with the same name?

Suppose I have two different directories with the same folder names: /usr/myDir/ and /home/myDir/ If I run a command such as: cd $(find / -type d -name myDir) it navigates to /usr/myDir. Why is ...
0
votes
1answer
30 views

Using if and find together

I'm trying to write a script that echos "success" if it finds .trc files older than 5 days in a directory. However I'm getting a full_path_trace': No such file or directory error even though my ...
4
votes
2answers
86 views

Purpose of find command's default size unit 512 bytes

The find command allows you to search by size, which you can specify using units spelled out in the man page: File uses n units of space. The following suffixes can be used: `b' for 512-byte ...
-5
votes
2answers
52 views

Find files that match a certain size and modification time?

How can I find all the files in directory greater than a certain size, say, 15 KB, and which have been modified in the last 10 days?
0
votes
1answer
45 views

Why does piping filenames into VIM break bash when I return to the shell?

I searched for a few files with find and I wanted to open all of them in tabs in Vim. So I tried this: find . | xargs fgrep -l myExpression | xargs vim -p This worked great, except when I was done ...
0
votes
1answer
50 views

How to “Find” then “Rsync” then “Tar/gz” on destination host?

I have a Cassandra node with snapshots broken up into 64 directories with over 350 files per directory. I want to "find" all snapshot files, preserve their location, rsync them across to a host with ...
3
votes
1answer
73 views

performance regarding “find” arguments' orders

I'm curious whether there are some distinguishing performance differences with different filtering orders when using GNU find. For example, I hope to search all directories in current path whose ...
1
vote
1answer
25 views

alternative approach for selective deletes from rsnapshot tree with find?

I'm looking for a generalizable solution to this problem, 'cause I'm sure it will come up again. I have a client that does medical research. Periodically we have to remove the datasets provided by ...
8
votes
1answer
116 views

Why do I end up with 4 invocations instead of 3 when using this find -execdir {} + (plus)?

I read here that you can count the number of invocations of command in -exec command {} + by piping | wc -l to the end of it. While I understand that -execdir is different, in that, for every ...
1
vote
1answer
34 views

Does the -depth option of find imply depth-first tree traversal?

As I understand it the -depth option of the find command causes the specified actions to take place on the way out of a directory (and maybe I understand it wrong) during a depth-first traversal of a ...
0
votes
2answers
24 views

Is this a better way to summarize the Synopsis of the find command?

In the man page for find I find the following in the synopsis: find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression] But after reading the man page I find it to be more like: find ...
1
vote
1answer
95 views

How do I find files older than 1 days using mtime? [duplicate]

I'm trying to remove all files more than 1 days old.Before I execute a script to remove the files,I try to find the files using mtime. however, I face same problem with my command- My Current date is ...
2
votes
0answers
66 views

use find command in bash file

I am using this script in my Linux machine to find all files that were modified yesterday: #!/bin/bash find /home/*/domains/*/public_html/ -name "*.php" -mtime -1 | while read line; do echo "$line" ...
3
votes
3answers
53 views

Using find in Solaris 10 to search a single directory but not its subdirectories

I'm trying to use find on Solaris 10 to list the contents of one directory, excluding subdirectories from the search. I tried a command based on the solution suggested by sdaau: find /tmp -type d ! ...
0
votes
2answers
48 views

Identify all files having no permission for others using find command

I want to identify all files which does not have any permission for others irrespective of any permission for user and groups . How the find command will look like. e.g drwxrws--- 2 jboss users 4096 ...
2
votes
1answer
85 views

How to get filenames when using find and sed

I am writing a script to apply sed on certain files and then list files that have been changed so that I know which have been modified. This is how I am finding and then using sed: find . -type f -a ...
20
votes
1answer
1k views

Why did find with -delete erase the files in my /save/ directory when find without delete was not able to locate them?

I want to delete all the files in the current directory tree, except those in save. I ran this command: find . \( -name save -prune \) -o -type f -ls | grep /save/ and it found none. But when I ...
1
vote
1answer
44 views

Delete files that do not contain “.zip” in their filename

I am trying to find and delete files that don't have ".zip" in it and is bigger than 1 Gig. I found the following command. Can someone explain to me what the following command is doing? /etc/home ...
0
votes
2answers
26 views

search the most latest's file name

I am writing a bash script to look for a file which's file name is most recently and file name like: ... Wed_Dec_30_16:47:41_PHT_2015.zip Wed_Dec_30_16:00:41_PHT_2015.zip ...