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

learn more… | top users | synonyms

0
votes
1answer
36 views

Pass filename from find and execute command

I'm trying to write a script which finds certain files and executes a command with the files it finds. Doesn't sound too hard, but I'm having a lot of trouble getting it to work. Basically this is ...
1
vote
1answer
167 views

How to Relink these symlinks after moving the system?

I moved my filesystem and symlinks from Ubuntu 14.04 to 16.04 by using FAT32 memory card, which apparently broke those links; stopped using BitTorrentSync. Differential condition is that those links ...
2
votes
1answer
50 views

Permission denied when using -exec {} ls with find command

When run following command it gives me permission denied message for all the files. find /data/code/ -name "*.jar" -exec {} ls \; find: `/data/code/project/shared/build/thirdparty/log4j-1.2.8/...
1
vote
4answers
67 views

How do I delete file by filename that are set as dates?

I want to delete file not by date access or created, but by filename. The filenames will be dates and I want to have a cronjob run once a week that will purge filename dates older than 7 days. I could ...
2
votes
2answers
163 views

find and remove files bigger than a specific size and type

I want to clean up my server from large log files and backups. I came up with this: find ./ -size +1M | xargs rm But I do not want to include mp3 and mp4. I just want to do this for log and ...
1
vote
1answer
40 views

Search files in a certain period and copy them into another directory

The problem is that I have a directory containing many files with extensions .xml, .txt and .p7m from year 2015 up today. I must create a script that searches into the directory 1 all files created ...
0
votes
1answer
29 views

Is there such a notion as broadening where find searches?

I'm trying to identify redundant installations of the site package matplotlib in my python3.5 environment. A contributor to the library (GitHub issue) is advising that I use python3.5 -m site ...
2
votes
0answers
50 views

find - No such file or directory albeit it exists

I run the following command on a directory: find . -name "*.pyc" -type f -delete however it prints this find: -delete: unlink(./tests/unit/framework/__init__.pyc): No such file or directory for ...
0
votes
1answer
27 views

Performing Prime Key function using 'Sed' in Bash

I am using bash and trying to employ sed command for matching a string and replace it with another between two files. Objective: To replace all strings[sp_*] by matching them from another file ...
2
votes
1answer
69 views

substring removal in find -exec

When using $ find . -name string~ -exec cp {} FOO \; is there a way to use {} in FOO to remove the tilde character as we usually do with bash substrings e.g. : $ echo ${string%substring} I ...
0
votes
0answers
51 views

Does `find` return directories that are not on the file system?

I'm trying to identify where the python site-package matplotlib is installed on my computer. I ran find ./ -name matplotlib at the top most directory (called the root, no?) and was returned the ...
1
vote
1answer
52 views

find X but exclude these?

Original find which works in OS X but not now in Ubuntu 16.04 find $HOME -type f -name "*.tex" -exec grep -l "masi" {} + | vim -R - (simplified version still; you can omit vim part but it just ...
1
vote
3answers
33 views

ln -s $SOURCE/* except - with find?

I want to do a symbolic link from all directories and files in the first node of $SOURCE to $HOME/Destination/. Pseudocode ln -s $SOURCE/* exceptThese $HOME/Destination/ Proposal find $HOME ! -...
2
votes
2answers
67 views

how can I find files based on different names and delete all them in one single line [duplicate]

Finding files based on different names I know how to do. The problem is that I don't know how delete all of them at once. I am using OMVS in z/OS390. To find files searching by different extensions I ...
2
votes
4answers
59 views

How do i find over 200K differently named files and output

We have a SAN with a lot (over 5 million) of files. Because of some freak mistake from a developer script, some files have been deleted and we now have to figure out which files got deleted. Now, I ...
0
votes
1answer
10 views

“find” doesn't list all files under specific directories

I'm attempting to get a list of all files under specific folders, recursively, with the "find" command. find / -path "/usr/sbin/*" -o -path "/usr/bin/*" -o -path "/usr/local/sbin/*"-o -path "/usr/...
1
vote
0answers
41 views

Simple code reading issue [closed]

I'm studiyng Linux on a guide as a beginner, and there's a code example I cannot understand. I let you it below: find . -name "*.tmp" -exec rm {} \; by reading it, up to now I can understand that ...
2
votes
4answers
53 views

Access a file located with find

In many cases after I find a file using the find command I then want to open the file or cat it or maybe print it. How can I operate on the result from find? For example, : find . -name "myfile.txt" ...
2
votes
2answers
89 views

find command, is there a way to get a progress report?

firstly please forgive my lack of knowledge of Unix - that's why I'm here after all. I've created an AppleScript which searches for files on a Mac and have greatly improved the speed by using the ...
2
votes
2answers
68 views

Bash script to count file types in a path (including subfolders)

I would like to get a quick overview over the different file types in a directory (including all its subdirectories) using the file tool, e.g. telling me what file type is the most common one there. ...
1
vote
2answers
124 views

find: meaning of the \? sign as a value of the name parameter

What is the meaning of the ? sign in the following command? find /foo/path -name \?
3
votes
4answers
75 views

find: do nothing, if no files get specified

I want to call use find on some filenames. find $(do_something to find filenames) -print0 | xargs -r0 ls -ld This breaks if $(do_something to find filenames) returns nothing: The find-command ...
0
votes
2answers
34 views

How do the {} and + get expanded inside find with the -execdir option

When using the find program with the -execdir option, I have seen people say the {} will be replaced with the directory and the + with the filename, but the manual does not say what these do. Is there ...
2
votes
2answers
69 views

How to Find LaTeX generated PDF files?

I need to find LaTeX Generated PDF files because I want to find those files made by me. I think find could possibly work here. OS X El-Capitan I run Ulrich's proposal find BitTorrentSync/ -exec ...
0
votes
2answers
54 views

Why can't 'locate' or 'find' find 'makeinfo'? [closed]

When I do: locate makeinfo OR find / -name "*makeinfo*" I get nothing. But when I do makeinfo --help, it gives me the proper help output. How is this possible? If makeinfo is an executable, it ...
1
vote
1answer
52 views

Extracting files to current directory

I want to find and tar/archive all my scripts ending .sh so I wrote something like that: touch ~/archive.tar; find ~ -type f -name '*.sh' -exec rvf ~/archive.tar {} \; The problem is that after I ...
1
vote
1answer
71 views

passing ls variable to grep when doing a file search only works inside directory

I am running a command that I use to find the most recent file in a folder then grep the contents for a matching pattern. Here is the command flow that shows the problem I am having. root@backup /]# ...
3
votes
2answers
138 views

find latest file created in folder and grep contents

I have a need to search a certain folder for the newest created file and grep the contents for a pattern. I have had ok success so far using this command: find /var/log/folder -type f -printf '%T+ %p\...
3
votes
4answers
102 views

'find -mtime -1 -print | xargs tar' archives all files from directory ignoring the -mtime -1 argument

I'm trying to create a backup script. I've managed to get this script working fine on a CentOS 6.7 machine and am now trying to get it working properly on Debian 7. I am running into a problem I can'...
1
vote
3answers
112 views

How can I recursively replace a string in file and directory names?

I have a git clone of etckeeper, and I'm trying to rename all files and directories with etckeeper in the name to usrkeeper. For example, ./foo-etckeeper-bar should be renamed to ./foo-usrkeeper-bar. ...
0
votes
0answers
43 views

How to create a symbolic link of all files in a directory using a shortened name obtained with using a piped cut on the filename

I have a directory full of libraries (*.so.0.*), and I want to use find to create a symbolic link to each file, named *.so.0. Here is a (non working) try: find $HOME/.local/lib64/ -name "lib*.so.0.*"...
1
vote
2answers
36 views

How to get all subfolder names consisting of uppercases only?

How to get the folders in a parent folder, the names of which are composed of A-Z, without lowercases, underscore, dot or any other things?
0
votes
0answers
47 views

find awk log print error

I'm trying to find one year old directories named in yyyymmdd format and print it in the log file placed at different location. find ${LOG} -maxdepth 1 -type d -mtime +${DAY} -name '20[0-9][0-9][0-9][...
3
votes
3answers
320 views

Copy subfolders containing at least n files

I have a folder root_folder containing a lot of subfolders. Each of these subfolders contains a small number of files (between 1 and 20) and I want to copy all the subfolders containing at least 5 ...
1
vote
1answer
18 views

Format for iname in Find operation

When using find what is the correct format to say "Find files that end in .jpg OR .png"? Is it as simple as using the | operator/character? find -iname "*.jpg|*.png"
0
votes
1answer
26 views

Linux red hat + replace PATH or word on scripts

Under folder: /var/userTN/applo folder I have around ~100 shell scripts that include the following PATH: GLOBAL_PATH=/export/pop/PLW5 I want to replace the PATH on all the scripts under folder: ...
0
votes
1answer
25 views

How to display only .txt files with the name ScheduledJobs in them

I have tried this: find ~/ops_scripts -type f -maxdepth 1 -name "ScheduledJobs*" but I'm not sure how to get only .txt files to display.
3
votes
1answer
51 views

Understanding the following find command

I am currently having a hard time understanding the following find command: find / -o -group `id -g` -perm \  -g=w -perm -u=s -o -perm -o=w\ -perm -u=s -o -perm -o=w \ -perm -g=s -ls  ...
1
vote
3answers
39 views

Script or command to list all top-level directories that contain sub-directories with modified files less than 30 days old

This is quite a unique one. I'm looking for a way to list all top-level directories in a folder that contain sub-directories with new or modified files less than 30 days old in them. We use a ...
0
votes
1answer
35 views

Recursive Directory search, Showing most recent file in folder

Can someone point out where am going wrong please. Am doing a directory search (Based on the folder structure and file type) The folder structure is the same for every customer. Just the customer ...
3
votes
2answers
286 views

How can I find files with a long first line?

currently I have a problem with a server. One user who is hosting a lot of sites got hacked and some of his php files were modified. Now I want to get a list of the infected files and also want to ...
1
vote
2answers
53 views

How to rename certain directories if the parent has a particular name?

I have to do some global renaming in an Eclipse plugin project, although the fact that the code is Java and it's an Eclipse plugin is irrelevant. Basically, the steps I need to perform are the ...
1
vote
2answers
77 views

How do I remove all files from wtihin a certain directory except for a child directory of that directory?

I’m using bash shell. I have this command to delete all JAR files within a particular directory find ~/.jenkins/jobs/subco/ -name '*.jar' -print0 | xargs -0 -r rm However, I want to modify the ...
0
votes
2answers
58 views

Finding special characters in name

How do I find files that have ~ * and other special characters in the name? e.g. find . -name "*\*" should match "any characters" and then *, but it matches nothing; how can I get the command to ...
1
vote
2answers
41 views

Finding files and directories with different umask

I have an umask as a 0002 using umask -S it returns u=rwx,g=rwx,o=rx. How do I find all files and directories that does not have rights set up according to mask? The directories goes 777 - mask and ...
1
vote
2answers
42 views

Regex in find - OS X

I cannot figure out what's wrong with my regex, it seems to be working with grep but now with find. I'm trying to find all the files which follow the common expression in TV shows e.g. S02E21. find -...
1
vote
1answer
43 views

Printing the file with number of hardlinks

I can print the number of hardlinks to files in directory by using find . type f -printf "%f %n\n" but this will also print the hardlink not only original files: Example: file1 is an original ...
0
votes
0answers
42 views

Fixing Signal 13 Error on find

I have a situation where I'm trying to install softwares into my system. I'm using a fakeroot approach to install them in a separate directory where I'm listing all the files, directories and links ...
1
vote
1answer
129 views

Evaluation of find ( -exec )

I'm searching for all files that contain one of a set of strings. If they do, I change their access rights. find . -type f -exec grep -q '#!/bin/bash\|#!/usr/bin/grep\|#!/usr/bin/awk' {} \; -exec ...
13
votes
1answer
203 views

Why does `find . -type f` take longer than `find .`?

It seems like find would have to check whether a given path corresponds to a file or directory anyway in order to recursively walk the contents of directories. Here's some motivation and what I've ...