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

learn more… | top users | synonyms

0
votes
1answer
31 views

Struggling with find

I have the following scenario: My directory-tree looks like this: /export/home1/user1/profile.V2 /export/home1/user2/profile.V2 my find command should find all profile.V2 directories: find ...
1
vote
1answer
51 views

How do I combine '-size` and '-exec rm' in find?

When I use this, it works: find /home -name "error_log" -exec rm -rf {} \; But when I try to add a file size limit, it won't remove any files: find /home -size +5000000b -name "error_log" -exec rm ...
0
votes
1answer
317 views

How to add subject line when sending email output of find using ssmtp

I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line. find /path/to/folder/ -type f -size +1M -name ...
1
vote
1answer
142 views

How do you assign {} to a variable in find --exec

I'm going to ask and answer this as I couldn't find the answer anywhere. I was trying to write a script that looped through each xml file in a directory and run make NAME= where NM was the filename ...
1
vote
1answer
46 views

copying and working on OSX .app files (folders) in linux

tldr; I want to run a script over an external hard drive and tar.gz every folder that ends with .app into their own archive. That is, I don't want them all in one tar.gz file, I want to create one ...
2
votes
5answers
211 views

How can I list the names of directories that contain file names matching a regex?

Given a directory X that contains several subdirectories and files, I would like to list the names of the immediate child directories of X that (directly or indirectly) contain file names matching the ...
0
votes
1answer
48 views

quoting problem when piping find output into xargs [duplicate]

I have a directory with the following subdirectories, i.e. If I run $ tree -L 1 . ├── 2007-06-20_to_2008-10-01 ├── 2008-07-21_to_2008_08_12-Nokia 2mp ├── 2009-11-01_to_2011-01-10 - All iphone Pics ...
1
vote
2answers
213 views

How does 'find -exec' pass file names with spaces?

If I have a directory containing some files whose names have spaces, e.g. $ ls -1 dir1 file 1 file 2 file 3 I can successfully copy all of them to another directory like this: $ find dir1 ...
2
votes
1answer
139 views

How to copy recursively all files not older than 1 day?

How to copy recursively all files not older than 1 day? I first tried find . -amin -1440 | xargs cp /dest But it doesn't work because the items given to xargs should be positionned before the ...
2
votes
3answers
275 views

How to iterate through files and delete those older than x days but NOT in use

So, I've been able to figure out bits of this myself but am having trouble piecing them together. I have a task I need to automate - I have folders filled with gigabytes of obsolete files, and I want ...
3
votes
5answers
492 views

Search files for a string and if found check if a file with paired name exists in the same directory

I have many different files with the same ending .ft1 that may or may not contain one specific word special. For the files that contain this word, I want to check whether another file with a different ...
0
votes
1answer
81 views

Cron to find exec cp and redirect output with time / date per line?

I try to setup a cron task to run a set of basic shell commands. I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date ...
0
votes
2answers
40 views

Only print filepath,without filename [duplicate]

The find command find /MOS -name "001.txt" The print /MOS/XNF/N01/001.txt My questions Which option could only print the filepath,without the filename ? The print /MOS/XNF/N01/
1
vote
2answers
36 views

Rsync two “filepath” found by find commands [closed]

Original file /001day/backup/001m/name_test_v1.txt Destination file /001date/003m/name_test_v12.txt Method 1 rsync -av --progress /001day/backup/001m/ /001date/003m/ Method 2 ...
0
votes
1answer
20 views

Cleaning script with find and anacron

I want to automatically delete old files in ~/Downloads. with exception of ones that have '!' in their name. My current version is as follows: find /home/user/Downloads/ -mtime +90 ! -path '*!*' ...
1
vote
2answers
100 views

Find works fine in command line, but won't work in script

I am trying to write a script on a Debian Jessie host. I am having an issue with trying to run the following command (with a twist) in a script: find ~/* -path ~/FileSniper* \ -prune -o \ -type f \( ...
1
vote
1answer
35 views

Search for file in folder1 and execute a script if that file isn't in folder2

folder1 contains only .flv files. folder2 contains only .mp4 files. All .flv files in folder1 SHOULD have a corresponding file ending in .mp4 in folder2 : /folder1/123.flv and /folder2/123.mp4. I ...
3
votes
3answers
76 views

Filter a list of files based on file attributes

With find you can search by file attributes like -type, -executable etc. How to achieve something similar, but from an existing list of files? e.g. the output of dpkg -L <package_name>. A pipe ...
3
votes
2answers
84 views

Why `find` likes `stat` or `fstat` so much?

I'm trying to make /usr/bin/find to show something meaningful without doing any sort of stat, with no useful results so far. If I forcefully inhibit stat, find stops descending into subdirectories at ...
2
votes
1answer
46 views

How to reuse file pattern in .gitignore in bash/zsh?

Here is the content of the .gitignore cron.yaml build target webview *.pyc *.sublime-workspace .idea *.rej .coverage app/tools/temp_*.py app/tools/*/temp_*.py I am currently iteraring files in a ...
0
votes
1answer
46 views

Delete Empty Folders - recursive [duplicate]

I would like to clean up some folders. So I want to delete all folders which are empty or only contain other folders... First I tried find . -type d -delete but this lists the subfolders after ...
1
vote
1answer
31 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...
3
votes
4answers
102 views

Moving a list of files by matching them to a destination index

Say I have two text files src.txt and dest.txt, where src.txt contains a list of filenames (some of which include spaces) in /src/dir/ and dest.txt contains, in random order, a list of the complete ...
3
votes
2answers
84 views

How can I list all files, but only in directories that have no subdirectories?

I have a directory tree that I want to search recursively for all files of a certain type (for example all .jpg's), but I only want to list these files if they are at the bottom of a directory tree. ...
0
votes
1answer
32 views

Shorthand alternative to find

Is there any alternative out there for find similar to ag and ack? I'm really tired of having to type: find some/app -iname "some_file*" I much rather just type: find "some_file*" And have it ...
2
votes
2answers
82 views

Faster search than find

Is there a way to find things faster than find . I am/was doing :- $sudo find / -perm +4000 But it takes ages to find the required info. and I know that most of the files which would that specific ...
1
vote
1answer
19 views

How do I write a script to automatically compile and install all Moksha modules?

I have this repository cloned on my Sabayon machine, what I would like to do is write a script that will change into each directory of this repo (just the top-level directories, not directories inside ...
2
votes
4answers
146 views

Find latest files

How do I find out the most recently accessed file in a given directory? I can use the find command to list out all files modified/accessed in last n minutes. But here in my case, I'm not sure when ...
2
votes
1answer
129 views

Bash script unable to move files

I'm trying to write a "janitor" script that will run as a cron job in one specific directory. It is supposed to create an archive folder with the date of creation in the name, and then find and move ...
1
vote
0answers
56 views

Chaining grep commands [duplicate]

I'd like to find all xml files containing 'foo', but not containing 'bar'. The command I've put together looks like this: find -iname "*.xml" -print0 | xargs -0 grep -FlisZ "foo" | xargs -0 grep ...
4
votes
3answers
214 views

Linux find-command skips a directory

I have certain network share folders mounted in the /media directory. I want to make sure that when I do something like sudo find / -name foo it should always skip the /media directory. I don't want ...
1
vote
2answers
65 views

Internal expansion with the find command and wildcard character [duplicate]

I'm still learning the command line and I am having some trouble fully understanding the use of the wildcard within the find command. I'm working in the directory user/temp and use the find command ...
7
votes
4answers
291 views

Execute a command where a file is found

How do I execute a command where a file is found? Consider I've an directory named testdir that contains the following: $ ls -R testdir/ testdir/: dir1 dir2 dir3 dir4 dir5 testdir/dir1: doc1.pdf ...
1
vote
1answer
225 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
152 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
55 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 ...
6
votes
2answers
1k 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
46 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
51 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
87 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
117 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
62 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; ...
0
votes
1answer
146 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
162 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
192 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
133 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
57 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
93 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 ...