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

learn more… | top users | synonyms

0
votes
1answer
27 views

find locations for a given sentence under a directory [duplicate]

Running a program gives some error messages such as these “ERROR File 'DATA/vgg16.npy' not found. I know this exact sentence should appear in one or more files under a given directory, which may have ...
5
votes
5answers
224 views

Find files for which multiple variations on that filename exist together in the same directory

I want to list the files for which there exists, in a given directory, ALL of these files: <filename>.wed <filename>.tis <filename>.are <filename>LM.bmp I am currently doing ...
0
votes
2answers
26 views

Remove all .class files from folders in bash [duplicate]

I'm making a bash file to remove all .class files that java generates inside the src folder and it's subfolders. The structure is: project src /utils utils.class /game ...
1
vote
1answer
19 views

how to find files of current date in remote server and copy those file to local server using rcp using shell scripting (ksh)?

I have two servers: 1.EOS(Linux RHEL 4) and 2.domain1(Solaris 10) In EOS, ftp rcp scp is blocked. In EOS, I have some backup files of oracle database saved in /user/orac/monthly/ path. My backup end ...
0
votes
1answer
41 views

Running find & grep, and include path in the output [duplicate]

On at least CentOS systems and previous versions of Fedora, I could run the following command and get a list of files with the corresponding grep matches: $ find -name "version.php" -type f | xargs ...
1
vote
4answers
76 views

Find file with smallest 4-digit-number

I have many, many files of the form [a-zA-Z]+\d\.\d{2}\_\d.\d{4}.end and want to find the file(s) with the smallest 4 digit number right before .end. (in case of collision I want all files) How can ...
1
vote
2answers
19 views

Escape whitespace in find for pdftk without xargs -J

I'd like to concatenate all PDFs in subdirectories, with filenames potentially containing whitespaces. I am well aware of this solution, find . -name *.pdf -print0 | xargs -0 -J FILE pdftk FILE cat ...
4
votes
2answers
144 views

Find unique values from find

I want to find unique files inside a directory, which also have sub directories. There are specific types of files, say .lib files. There are same .lib file inside different sub directoris. I need ...
2
votes
2answers
37 views

How to recursively search for directory by name and delete all regular files in it

I'm working on a bash script in an AWS EC2 instance (RHEL derived) which needs to do the following: Search for all directories named "_combined" in ${PROJECT_DIR} Delete all regular files in all ...
3
votes
5answers
123 views

Find files containing keyword and show only the file path and the line number

I'd like to find all the Java files containing keyword File.createTempFile with the line number. Here's what I did: $ find . -name "*.java" | xargs grep -n "File.createTempFile" ./nuxeo-studio-test/...
8
votes
2answers
608 views

Find oldest files/directories in file system up to 50 TB

I need to find the oldest files with their associated directories in a 90 TB file system up to 50 TB and then move them to another file system. They have to retain their directory structure as that ...
0
votes
1answer
17 views

How to exclude folder name regardless of path in bash? [duplicate]

I am trying to exclude folders from being searched in for files. It actually works relatively well. My code looks like this: find . -type d -regextype posix-extended -regex "(./Scripts/testfolder)" -...
-1
votes
1answer
35 views

Getting “No such file or directory” when deleting directories with find

I'm using Amazon Linux. I have this statement that is designed to remove files in a directory /bin/find $JBOSS_HOME/standalone/tmp/vfs -mindepth 1 -mmin +1441 -exec rm -rf {} \; But this results in ...
-1
votes
1answer
52 views

Delete all logfiles from system

I need to delete all the log files older than one month from a Linux server. However the query below does not work: find -type f -name "*.log" -exec rm *.log {} \; and I don't know how to ...
1
vote
2answers
58 views

How to exclude files/directories from find using program argument in bash?

My find looks really simple: find . -type f I'm trying to figure out how to exclude certain files or directories, depending on the program argument line. bash myscript.sh -excl a b c d Where a, ...
2
votes
2answers
76 views

How to create tar.gz of each file of a particular type in single command?

I need to compress and decompress each of the files of a particular type say "*.html" in their respective location. For decompression, I used following command, it seemed to work for me: find dir -...
7
votes
4answers
418 views

Is it possible to exclude a directory from the find command? [duplicate]

I am using find -type f command to recursively find all files from a certain starting directory. However, I would like to have some directories prevented from entering and extracting names of files ...
4
votes
3answers
115 views

find script should remove empty dir recursively after it removes files in it

I've this find script that finds files in home dir more than 100 MB of size and delete if it is more than 10 days old. It is scheduled for everyday one time by cron job. find /home/ -mtime +10 -type ...
3
votes
2answers
60 views

What purpose does the minus (-) in `find -! -exec` serve?

In this answer, what is the use of -! in find? Consider the following code: find . -type l -! -exec test -e {} \; -print This alternative seems to do the same exact thing: find . -type l ! -exec ...
4
votes
1answer
63 views

Can I tell find to to not restore initial working directory?

find isn't able to ‘restore initial working directory’ when run behind sudo -u if the initial working dir is not visible to the user find runs as. This causes find to always print an annoying ...
0
votes
1answer
32 views

Find file with longer of its name [closed]

Please, How can I find a file in folder that start with a character (for example 'A') and the longer of file name does not exceed 8 ? I know to find a file I use find fileName, but how about the ...
0
votes
1answer
25 views

Parallelize recursive deletion with find

I want to recursively delete all files that end with .in. This is taking a long time, and I have many cores available, so I would like to parallelize this process. From this thread, it looks like it's ...
-2
votes
0answers
15 views

how to find files within range of time but on any day? [duplicate]

Lets say there are few thousands of files with creation time between week (year, whatever...) ago and now. I need to find files which were created between X time and Y time (e.g. between 19:00 and 06:...
1
vote
1answer
56 views

Using for loop with find command

I want to read all java Versions on my system. for i in 'find / -name java 2>/dev/null' do echo $i checking $i -version done I receive an error: find: paths must precede expression: 2>/dev/...
0
votes
1answer
56 views

Can list of directories be parsed into a find command?

Suppose I want to unzip files recursively that have the pattern ${file}*.zip in some directory /home/A/XML using find command find /home/A/XML -type f -name "${file}*.zip" -exec unzip '{}' -d /target/...
2
votes
5answers
101 views

Quick way to open results from `find` or `locate`

When I run find or locate, the matching files will populate stdout, one file per line. The next step is often that I want to open one of these files. This would be faster and more efficient if I did ...
8
votes
7answers
436 views

Find list of directories one level deep from matching directory

I'm trying to get a list of directories that are contained within a specific folder. Given these example folders: foo/bar/test foo/bar/test/css foo/bar/wp-content/plugins/XYZ foo/bar/wp-content/...
1
vote
1answer
54 views

find command output empty when redirected to a file

I am trying to obtain a list of files using the find command as follows: find . \( -iname @eaDir -o -iname .DS_Store -o -iname Thumbs.db \) -prune -o -mtime -25 -type f -printf "%P\n" This is ...
1
vote
2answers
65 views

Difference between dot and asterisk in find command

I have a Synology NAS, which uses a customised Linux for its OS. Using the find command, I am trying to list the files modified since about 25 days, with some exclusions, within a particular directory....
1
vote
2answers
61 views

Applying the chmod and chown commands dynamically to the output of find command

I have a file inside many directory from within a root directory. I need to apply the chmod 640 and chown command on all the files. I have two commands, one to find the file paths and the other is to ...
0
votes
2answers
35 views

Does '8.5.6 ‘grep’ regular expression syntax' in findutils' manual refer to `grep`'s syntax for BRE or ERE?

grep -G supports Basic Regular Expressions, grep -E Extended ones, and grep -P Perl ones. Does Section '8.5.6 ‘grep’ regular expression syntax' in findutils' manual https://www.gnu.org/software/...
5
votes
5answers
194 views

Find fullpath and filename under a directory then pass to an executable file as arguments

I'd like to find fullpath and filename of all .txt under a directory, and pass to a executable file ./thulac . It cost me some time to reach: find /mnt/test -name "*.txt" -print0 |xargs -l bash -c '....
0
votes
1answer
56 views

Simple bash script for backing up and deleting directories

I have made this and surprise, it isn't working #!/bin/bash cd /home/test/backup cp -a vaults backup/vaults-$(date +%d-%m-%y-%S) find backup/vaults-* -mtime +5 -exec rm -r {} \; I need it to ...
-1
votes
1answer
25 views

Redirect errors to /dev/null when greping and finding on Solaris

I find myself having to play around with Solaris. I would usually redirect with 2>/dev/null which works on Solaris in general, but not with these two ways of doing recursive "greps" on Solaris. # ...
0
votes
1answer
33 views

Combining enscript, find, iconv and ps2pdf

I'm trying to write a small bash script that'll convert source files in a directory to a .pdf. The steps are these Locate files with find execute iconv on the files converting the character encoding ...
1
vote
0answers
26 views

Emulating git status --ignored in non-repository folder

This might be in essence a duplicate of this question, however the perl script provided did not work in my case as far as I can tell. There are also many questions about finding multiple patterns, but ...
3
votes
0answers
55 views

find command does not find if starting in parent folders

I want to print a list of all the files I own, so I use the find command, but it is not working properly, it misses some files, so I tried to find those specific files. In my home folder (say, /us/...
0
votes
2answers
68 views

How to find and run a bash script?

I have a script named script.sh. I don't know where it is in the file system, but I do know it exists. How do I find the script, make it executable, and run it all in one line through the command ...
3
votes
2answers
63 views

add subdirectories to $PATH in bash using find

I tried this PATH=$PATH$( find $HOME/scripts/ -type d -printf ":%p" ) but it works only on Linux, on OSX (or Freebsd), it's not working because -printf is not POSIX. How can I write a compatible ...
0
votes
1answer
36 views

How to unzip a few directories with zip files which also contain sub-directories with zip files?

I've 4 folder & inside each of them, there're a folder XML that contain zip files & some folders with zip files All of the zip files contains files in XML format /A/XML/: BDL_DCR_20170216....
3
votes
3answers
72 views

Can I find all files with the .log extension and order by file size?

I'm using CentOS 6.8 I'd like to know if I can I find all files with the .log extension and order by file size and display the file size next to the filename? I'm currently using this command to ...
3
votes
0answers
31 views

How to copy from multiple SRC directories to single DEST

Is it possible, with find and rsync, to recursively copy a specific file type, but ignore the directory structure when writing to the destination? In other words, to copy every zip file from every ...
0
votes
1answer
38 views

Find all zip files created today in a directory and its sub directories based on a pattern

I have multiple zip files in a directory and its sub directories with the pattern ACCT_DOC. example T.6593.ACCT_DOC.1054.1_0.20170220.111425.zip T.12561.ACCT_DOC.1003.1_0.20160121.221947.zip I ...
1
vote
0answers
32 views

rsync creates a directories with the same name inside the destination folder

I am trying to rsync only .bin files from folders beginning with 11.* and 14.* (including sub-folders), not older than 1 day. What I have tried so far: rsync -Rarv `find /mnt/IP/ftp/123/ -type f -...
0
votes
3answers
46 views

get all file names in subdirectories

I need to get all file names, not including the paths eg file1 is correct and ./folder/file1 is incorrect, from subdirectories. My use case is retrieving all available terminfo file names which are ...
1
vote
2answers
127 views

find -exec sed to find / replace with reusable string

I am trying to build a small sh script that does a basic find / replace but with a small twist, that I wonder if I am going about it the wrong way. here is the old string mysql_fetch_array($foo) ...
0
votes
1answer
28 views

find and rm -rf, why it prints errors? [duplicate]

I'm definitely doing something wrong but can't figure this one out. When I run rm -rf on directories through find I get a No such file or directory but it does not happen when I do it manually. ...
9
votes
2answers
590 views

In a `sudo find` command, how do I make sure that `-exec` command is run as normal user?

I am trying to make the following command work in a way that process_paths script is not run under elevated privileges. Is there a way to do this? sudo find /path/ -exec process_paths '{}' \+ Here /...
0
votes
2answers
42 views

chmod files with group - error on files with (

I have the need to chmod files which are in a certain group. I have come up with this construct: find . -group groupname -exec sh -c 'su -c "chmod -R u+w,g-w,o-w,g+r,o+r ." - groupname {}' \; This ...
0
votes
2answers
30 views

In what way does quoting parameters to `find` matter? [duplicate]

When looking for txt files, I run this command: find . -name "*.txt" -print This gives me a list of all the text files beneath current directory. However, find . -name *.txt -print gives me the ...