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

learn more… | top users | synonyms

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
79 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
68 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 '{}' +...
1
vote
2answers
111 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
148 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
69 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
52 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
122 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
258 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
57 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
104 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
177 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
36 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
252 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
58 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
60 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
39 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
31 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
97 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
55 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
53 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
55 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
78 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
29 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
118 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
45 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
114 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
71 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
58 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
89 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
46 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
27 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 Wed_Dec_30_16:00:41_PHT_2015....
1
vote
2answers
40 views

files per directory in a single line

I have following directories: Sample1 Sample2 Each of it contains multiple subfolders like Sample1/R1/ Sample1/R2/ Sample1/R3/ Sample2/R1/ Sample2/R2/ Sample2/R3/ Which further contains ...
2
votes
1answer
219 views

how do you find all files and directories without sticky bit?

how do you find all files and directories without sticky bit? I have a bunch of old files that I need to delete so I use: find . -mtime +3 -a \( -type f -o -type d \) But then this find command will ...
2
votes
1answer
30 views

Find all git repos that do not contain any one of .gitignore and .gitattributes

I basically want to find all git repos that have neither a .gitattributes nor a .gitignore file at the root. I used find . -type d '!' -exec test -e "{}/.gitignore" ';' -print to find it but it lists ...
0
votes
1answer
38 views

Finding files that have been modified using a script?

I need to find files in a given directory that have been modified in the last N days, where N is the second argument of the script. Basically, I need to give the command with 2 numbers (arguments) and ...
8
votes
5answers
245 views

Why does find sometimes match its command line path argument?

On Linux, cd /tmp mkdir foo; cd foo Now, running find . -name 'foo' gives no output. Whereas running find /tmp/foo -name 'foo' Gives the output /tmp/foo which doesn't make sense to me. Can ...
1
vote
1answer
51 views

Add one line to all found files

My original working directory hierarchy: $ find . ./usr1 ./usr1/.vimrc ./usr2 ./usr2/.vimrc I want to add one line -- "set number" -- to all .vimrc files. So I ran this command: find -name ".vimrc"...
1
vote
2answers
60 views

Usage of prune not working in find command

I am trying to use prune as: find /opt/app/bss/sieb/fs_clone1/userpref -name "*" -type f -mtime -7 -prune This is still searching sub-directories.