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

learn more… | top users | synonyms

2
votes
4answers
102 views

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

I've bunch XML files which I would like to move to corresponding folders with the same name. Here is sample structure (in shell): touch foo.xml bar.xml "[ foo ].xml" "( bar ).xml" mkdir -p foo bar ...
0
votes
2answers
41 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
33 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
29 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
16 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
35 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
24 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
47 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
38 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
29 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
28 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
68 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
16 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
110 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 ...
0
votes
1answer
24 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
51 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
56 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
38 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
46 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
75 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
33 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
25 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 ...
1
vote
2answers
37 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
33 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
21 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
22 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
224 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
31 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 ...
1
vote
2answers
23 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.
0
votes
2answers
40 views

How to recursively change permissions on all directories inside current directory?

How can I change folder and file permissions for all files and folders recursively inside current directory? I am not sure, why, but my command fails with this output: chmod: missing operand after ...
0
votes
1answer
21 views

How to set up a pre-defined variable with multiple directory paths to use with the find command

I am looking to have a script delete files that are older than 90 days in certain directories. As in, there are 8 directories that have different paths to them. I can run the find command on one ...
-4
votes
1answer
34 views

find problems again? [closed]

How do i show pipe or socked files from a directory? echo "give name of directory: " read directory if [ -d "$directory" ] then echo "thanks again" else exit fi find $directory -maxdepth 1 -type ...
0
votes
3answers
21 views

problem with find (shell script)

I want the files of a given directory and use the following script: echo "give name of directory: " read directory if [ -d "$directory" ] then echo "thanks again" else exit fi find /-type f ...
4
votes
2answers
68 views

How to modify files on Unix to avoid file purging policy?

We have a policy on our cluster that any files not modified or accessed within 30 days will be deleted. I have a project running and I want to keep all files until I finish it, would it be possible to ...
1
vote
3answers
53 views

Find Directory if Number of files is over X

Am wondering if someone can advise on the best way to do this. In my Web Dir is around 100 folders; each folder is a clientID. Within each ClientID folder is a Sub-Set of folders. In each subset ...
1
vote
2answers
56 views

Listing line number of results in `find` and `ls` [duplicate]

Is it possible with either find or ls to see, in a list of results, if any given entry is the nth result, what n is? So, for example, pretend ls -l returns: total 0 -rw-rw---- 1 bigdog bigdog 0 Jan ...
0
votes
2answers
32 views

Why doesn't this find command work? Regex & Find variants for .mp3 .wav and .m4a files

2015.10.25 Move on and Be Blessed.wav dummy.m4a 2015.11.17 BS Full.wav.mp3 2015.11.17 BS MOL.wav.mp3 find . -name '*.mp3' -o -name '*.wav' -o -name ...
5
votes
5answers
268 views

Rename files based on their parent directory using find/xargs command?

I have a directory structure like this: Project/ | +--Part1/ | | | +--audio.mp3 | +--Part2/ | | | +--audio.mp3 | +--Part3/ | | | +--audio.mp3 ... I want to ...
3
votes
2answers
98 views

Find all files modified around a known one

An installer which isn't really clean (Adobe Acrobat Reader DC) installed on my Unix (Mac OS X) a lot of files in different places. I have a reference file Application which I am pretty sure was ...
4
votes
2answers
52 views

Invert matching lines, NUL-separated

I’m writing something that deals with file matches, and I need an inversion operation. I have a list of files (e.g. from find . -type f -print0 | sort -z >lst), and a list of matches (e.g. from ...
1
vote
2answers
26 views

Find file type reverse

On my image folder i want only images,so i will find all video files "intruders" using this command(found somewhere on stackexchange) find folder/imageonly -type f -exec file -N -i -- {} + |sed -n ...
2
votes
3answers
30 views

Find files with group permissions more restrictive than owner permissions

This is an actual work-related problem. Users could previously "su - userx" and was able to execute a script with user:owner permissions as userx:groupz 760 or 540, or modify a file that's ...
3
votes
1answer
313 views

I want to list all the files in my Linux server which are older than Dec 31, 2014

I want to list all the Linux files in a directory and sub directories which are older than 31 Dec 2014. Please help me out for this.
1
vote
1answer
37 views

find: missing argument to « -ok » [closed]

A while ago, I ran chmod to change some file permissions to 777. A friend of mine told me to never chmod 777, so I decided to change the permissions again. So, first I looked for all the 777 files: ...
1
vote
1answer
49 views

find command match issue [duplicate]

I'm having some trouble while searching files with find command and the way it handles the search. Let's say I'm currently in the directory /tmp and the directory contains the files: ...
1
vote
3answers
81 views

How to find empty directories in unix [duplicate]

I want to show all the empty directories under my home directory, using shell script, can you help me find the code? (without using find's -empty)
4
votes
1answer
282 views

Why GNU find -execdir command behave differently than BSD find?

On my OSX, I've installed GNU find next to default BSD find via: brew install findutils. As far as I understand, BSD find is following POSIX standards and GNU makes it optional (as per this post), ...
3
votes
1answer
195 views

Odd alias “find . -name '*\!{*}*' -ls” in Unix Power Tools

From Unix Power Tools 3rd Edition page 175: Article 9.27 shows a way to match directories in the middle of a path. Here's a simpler "find file" alias that can come in very handy: alias ff ...