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

learn more… | top users | synonyms

1
vote
1answer
264 views

Find files older than a given file - a few hours

I'm using the following to find all files that are older than a reference file... find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt ... which works as expected. However, I want to ...
1
vote
1answer
19 views

What changes are made to ./.dns?

My server hosted at Hostgator was recently hit by malware and hence to monitor the file system I use find -mmin -xx command at regular intervals. But everytime I run the find command, I see the first ...
0
votes
5answers
190 views

Find all [filename].mp4 and rename [filename].audio [duplicate]

So I have a script that adds 2 films together using the audio from the $1.audio file. What I would like to do is rename any file in the directory with: *.mp4 To: *.audio Keeping original file ...
3
votes
1answer
64 views

Recursive find/replace, taking directory depth into consideration

I've had good luck doing basic find/replace: find . -name "*.php" -exec sed -i -e "s/<?php include 'http:\/\/www/<?php include '..\//g" \{\} \; I am wondering if there is a way to achieve a ...
7
votes
2answers
2k views

Find files newer than 15 seconds but older than 2 seconds

I want to find files newer than 15 seconds but older than 2 seconds. Here is the script I'm currently using that grabs files newer than 15 seconds: find /my/directory -name '*.jpg' -not -newermt '-15 ...
1
vote
1answer
49 views

Having trouble with img2pdf and spaces in filenames

I am trying to convert a bunch of jpeg files to a pdf file. When I type the filenames with the quotes all is fine: $ img2pdf "./Page 001.jpg" "./Page 002.jpg" -o book.pdf When I go for the ...
2
votes
2answers
56 views

How to delete files if a numerical part of their name is greater than a given number?

I've got files like this: cap_20151023T122915_791033959.png cap_20151023T122918_946392456.png cap_20151023T122920_227637228.png cap_20151023T122920_875467456.png and I would like to use the find ...
0
votes
1answer
38 views

How to improve search time for searching files in a lot of directories

I have to search for 3 types of files throughout a lot of directories (easily 1k + I think?) some of the files are 13 level deep. installer.jar Installpackage_*.jar Patch_*.jar Right now I am ...
1
vote
2answers
100 views

Using rename to remove '.orig' from file and add '_1' to basename

I'm using a script to make backups of files, and to avoid overwriting files I've used cp --backup. Which leaves me with a number of files that look like example.mov.orig and test.mov.orig. I cannot ...
1
vote
3answers
138 views

Rename all files in directory while preserving any file extension

I have folder with about 1200 files that I need to rename. Theit file extension is .jpg, .gif, and .png for the most part. Here are some examples: Awesome\ FB\ \ (462).jpg Bonus\ FB\ ...
1
vote
2answers
65 views

Where is my downloaded file

I tried to install java runtime with the following commands su - cd /opt wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=...
0
votes
1answer
182 views

c shell script: find the directory and rename it

i am still new in this shell script. I have a task that given to me which i have difficulty to execute it. The task is i have a lot of directory which is based on ddmmyy. 03Mar2014 08Aug2013 ...
2
votes
3answers
178 views

How to exclude the file type in find , exec and grep?

I am trying to find out the file in which the following flag is used - TRACE_WANTED". However, I don't want the find to search this flag in .c and .h. How can I issue a command to exclude the find ...
-3
votes
4answers
226 views

bash: ls -l with grep

I have this: find . -type f -exec file {} + | grep ASCII This is the output: I want to know if is possible to show the size of the files and their path, for all files that file indicates as ...
1
vote
2answers
175 views

Find all .php files inside directories with writable permissions

I'm looking for a linux command to scan through all writable directories on the server and show ones with .php and .html files inside them. Something like: find -type d -writable -exec find {} -...
0
votes
3answers
59 views

Grepping the output of find

I am looking for a folder, but there are a lot of Permission denied messages. I want to filter these out by grepping the output. I tried this, informed by other questions: find / -type d -name '...
2
votes
0answers
110 views

Backup using find and ssh to off-site server

I'm sure this has been been answered in bits and pieces on many sites, but somehow I can't seem to get this (as a whole) to work reliably. Scenario: I have a server that I would like to do ...
3
votes
1answer
62 views

OpenBSD: Move directories larger than X to new directory

I'm accessing OpenBSD via SSH and I'm wanting to create a command to find directories larger than 20MB and copy them to a new directory, keeping all folder structure. So far I have this: find /...
1
vote
0answers
79 views

Help with MKV to MP4 Remux script [closed]

Overview: I'm trying to remux my mostly MKV library to MP4. I have a script that has gone through and extracted subtitles from the video files. I have another script that will remux any .mkv files ...
4
votes
3answers
196 views

Remove long string from files

Files on my server have been corrupted. I want to remove a 13000 character string from all PHP files containing it. The string looks like: ?php if(!isset($GLOBALS["\x61\156\x75\156\x61"])) { $ua=...
3
votes
3answers
133 views

Using basename to strip file extension and search for files with the same name

Basically, I have a folder /test/ that has a number of files of type .doc and .pdf. Some of the files have a .pdf and a .doc version, such as test.doc and test.pdf while others only have one version. ...
0
votes
1answer
130 views

How to use find command to execute two conditions in linux

I am trying to delete files (log files) which are more that 5 days old and I need to keep one specific file without deleting, I tried it using find . -type f -mtime +5 ! -name 'test2' -exec rm -f {} ...
0
votes
1answer
4k views

find: cannot fork: Cannot allocate memory

I want to delete 1 file at a time from my directory which contains so many files,So i want to remove 1 file at a time. Just to avoid too many reads and failed at too many arguments. find ./Backup/...
0
votes
2answers
43 views

Find the position of repeated character “&”

How can determine the position of “&” in the column number 5 to substring the value 2 or substring value 3 by awk functions column1|column2|column3|column4|variable1:value1 & variable2:...
0
votes
0answers
19 views

How to exclude path in “find” [duplicate]

How to exclude Time Machine backup folder (/Volumes/Backup/Backups.backupdb) in find? I have now this but it also goes through TM folder: do shell script "find -x " & fr_where & " -print0 | ...
1
vote
1answer
36 views

Pruning not working In find

find . \( -type f \) -o \( -name "*.rpm" -prune \) find . \( -name "*.sh" \) -o \( -name "*.rpm" -prune \) The second command excludes .rpm but the first one doesn't. What's the problem with ...
0
votes
1answer
52 views

What is the barebones simplest way to recursively rename one extension to another? [duplicate]

I've done a fair share of googling and I've found some rather complex solutions. I feel as though there must be something simpler. Let's say I have ./1.txt ./2.txt ./more/3.txt ./more/4.txt ./more/...
0
votes
0answers
147 views

rsync, find, and other useful commands for synchronizing a large quantity of data

Here is the structure of the folders I would like to consider: /mnt/network/ is my network drive and /local/ is my local folder. What I want is to synchronize the content of these two folders (...
2
votes
4answers
485 views

Human-readable filesize with find's printf

I am writing a simple helper function to show a specific folder in the format I want: find . -maxdepth 1 -not -name "." -printf '[%TY-%Tm-%Td]\t%s\t%f\n' | sort -n However I want to show the ...
2
votes
2answers
86 views

Combination of find command and sed (stream editor)

I am trying to find all directories in /proc with names containing only numbers and belonging to users other than "root" I have already tried this: sudo find /proc -type d -user | sed -n '/[0-9]/p' ...
0
votes
1answer
56 views

find by name or by grep

find . -perm -u+x,g+x,o+x -type f -exec grep -i -l -H -E '#!/bin/bash|#!/bin/sh' {} \; 2>/dev/null 1>/$user_scripts I am tasked with finding any script that could exist for N users in 4 ...
1
vote
3answers
166 views

Combination of find and grep command with exec option

I am trying to find all files inside /lib /lib64 folders that contain "lib" in their names and print that file names without extensions (.so or similar), avoiding identical names in output. My way is:...
3
votes
2answers
117 views

Using find -exec how to print name of file in front of each line?

Similar to, but beyond: find . -iname "somepatter*txt" -print -exec cat {} \; How might the file name from each file be printed in front of each line with the results from find?
1
vote
0answers
41 views

What are the major differences between the Darwin/BSD and GNU versions of Findutils?

OS X comes with its own versions of find, locate, and xargs. GNU versions of these utilities are also available as part of GNU Findutils. What are the major differences between the two versions? Is ...
1
vote
1answer
121 views

Recursively delete subdirectories not containing pattern on OSX

I am trying to delete all sub directories (and files inside) that do not contain one of two patterns in the directory name using Bash on OSX. I am trying to do this recursively - for a bunch of parent ...
0
votes
1answer
368 views

Copy all files matching criteria on find command with -exec

Below are my attempts at copying all files except .out and .class files into a subdirectory titled homework21/. Note homework21 is a subdirectory of the folder in which I am working in. me@ice4:~/...
2
votes
1answer
222 views

How to get list of files with not having search string [duplicate]

I have a requirement to display all files in a directory which doesn't have CountOfFilesTransmitted=0 string in them. If I give below command it gives only those files which has ...
3
votes
2answers
134 views

Why does deleting directories generate error messages with find -exec?

Why is it that: find . -type d -name test -exec rm -r {} \; generates error messages: find: ./foo/test: No such file or directory find: ./bar/test: No such file or directory find: ./blech/test: No ...
4
votes
2answers
71 views

How to use the results of “file” (Name of Creating Application: Microsoft Word) to search for a specific string?

I am trying use the results of "file" which returns info about the file/s I specify. E.g. file *.doc 'all .doc extensions This then returns information about the file including "Name of Creating ...
0
votes
2answers
63 views

sed search and replace problem

I am trying to replace a string from a file which contains '&' in its value. vari = '111|abc & efg|123' varj = '222|abc & efg|123' echo $vari | sed -e "s/$vari/$varj/g" output is 222|...
1
vote
1answer
50 views

Can I use Zsh's built-in wildcard matching to replace the use of `find` here?

This is a follow-up to another question I posted I use a script to automatically rename files according to a particular order: #!/usr/bin/env zsh pages=($(sed -n '/page_order/,/^$/ p' _config.yml | ...
6
votes
1answer
51 views

GNU find -[cma]time option and daylight saving time

In the GNU find man, you can read this about the -atime option: -atime n File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last ...
2
votes
2answers
109 views

Identify sub-directories that do not contain a specific string in a specific file

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I need to find sub-directories that either do not contain a file stdout or if they do, that ...
0
votes
1answer
107 views

find command doesn't find (readable) files as non-root user

I'm trying to figure out why find does not find my files, even when they are readable. I have the following directory /some set up drwxr-xr-x 2 root root 4096 Sep 23 16:45 some It's readable by ...
2
votes
1answer
70 views

Check for related file names and delete one of them

I need to write a script that will find files that contain a string in their name. If a file exists that is the same name but without that string, I want to remove the original file. For example, if ...
-2
votes
1answer
67 views

Find part of filename

Please help with my task: I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names. I need to create a shell script ...
1
vote
2answers
60 views

xargs repl_str doesn't expand second placeholder

I would like to rename some files and exclude others into a directory. I tried find . -mindepth 1 -maxdepth 1 ! -name 000-default.conf ! -name default-ssl.conf -print0 | xargs -0 -I {} sudo mv -- {} $...
0
votes
1answer
409 views

Find command to check only for the last 10 minutes and not the whole folder

I have an nvr system that recording video surveillance into a file server (Debian). I made a Nagios plugin to check if the NVR system is recording correctly and send me a notification when it stops ...
1
vote
1answer
21 views

copying sub-directories not containing a specific file into another directory

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I get the list of sub-directories that does not contain a file stdout based on solution given ...
0
votes
1answer
31 views

Find filename using list inside a file

How can i find all filenames that match a string in a list inside a file? I have a list_file.txt with a list of email addresses each in a new line like this: 1@mail.com 2@mail.com 3@mail.com ... ...