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

learn more… | top users | synonyms

4
votes
5answers
850 views

Clone directory tree structure and copy files to the corresponding directories modified after a specific date

I have a folder with more than 30 sub directories and I want to get the list of the files which was modified after a specified date(say sep 8 which is the real case) and to be copied with the same ...
3
votes
1answer
56 views

List File Space Ownership By User

I have a 4TB NFS file system that is being served from a NetApp filer. The NetApp's quota tools tell me that a certain user is using X amount of disk space in that qtree, but it isn't in "their" ...
9
votes
1answer
354 views

Is it possible to use `find -exec sh -c` safely?

I'm trying to use find to echo 0 into some files, but apparently this only works with sh -c: find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \; But using sh -c with find -exec ...
2
votes
2answers
58 views

Reference a path name in `find` output results

What I would like to do is to be able to reference a find path name result as a parameter to another command without laboriously typing the full path name. Example: $ find -name testfile path1 ...
0
votes
1answer
105 views

Delete empty directories using 'ls' command

I want to delete empty directories without using find command find . -empty -type d -delete. like the following: if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi How do I ...
1
vote
1answer
49 views

Find files in multiple directories taken from list in a file?

FreeBSD 9.2 RELEASE p2 I have a file dirs.txt. In this file is a new line separated directory list like so: /etc /home /home/goods/ I need to first find in all directory's files which have names ...
2
votes
1answer
270 views

how to find and then delete files older than specific days in unix including files in subdirectores not touching folder structure

I have got one folder for log with 7 folders in it. Those seven folders too have subfolders in them and those subfolders have subfolders too. I want to delete all the files older than 15 days in all ...
5
votes
4answers
386 views

How can I cat the contents of files found using find into a single file?

I managed to shoot myself where it hurts (really bad) by reformatting a partition that held valuable data. Of course it was not intentional, but it happened. However, I managed to use testdisk and ...
0
votes
2answers
64 views

Remove by date in Shell Script

I have a shell script that creates a backup of a database. I would like to keep the last 7 days for files. What is the syntax I need to remove files in a directory by date or can I keep the newest 7 ...
1
vote
2answers
63 views

Find doesn't want to find *.sh in certain level [duplicate]

I have a problem with find. It doesn't find *.sh files if I am in certain directory level. It does, however, find *.sql files. /path$ cd do_not_upload/updates/1.1.1/ ...
3
votes
3answers
594 views

How to integrate mv command after find command?

Given a scenario I was searching for file name which contain AAA withing it on a path using following command: find path_A -name "*AAA*" Given the output shows from the above command, I want to ...
6
votes
3answers
741 views

Meaning of @0 in a shell script

I was looking at the script /etc/init.d/sudo in my Ubuntu 14.04 Linux system. While reading the script, I found this statement : find /var/lib/sudo -exec touch -d @0 '{}' \; What is the meaning of ...
0
votes
2answers
57 views

Find an archive and extract it in the directory where it is located

I want to find a tar file which is presented in any directory and un-archive it in a one line command. I am able to find it separately from home directory. but only can extract it from directory ...
1
vote
1answer
204 views

make `find` return with a non-zero exit code if error occured

Why am I seeing the following: $ find -not -exec bash -c 'foo' \; -quit bash: foo: command not found $ echo $? 0 This is a reduced version of the actual script I am using which I post at the end ...
0
votes
1answer
45 views

Improve execution time for recursive md5sum check?

This recursive md5sum check for 40000 items of 11.8 GB takes 2 minutes: ret=$(find "${target}"/ -name ".md5sum" -size +0 | while read aFile; do cd "${aFile%/*}"; md5sum -c ".md5sum"; done | grep -v ...
1
vote
1answer
65 views

ls and find command excluding a certain directory

I want to do this: ls -altrhS 'find / -type d \( ! -name tmp -prune \) -size +10000k 2> /dev/null -print' | egrep -v 'ibd|MYD|MYI' So I want to list, in that format, files of a specific size ...
2
votes
3answers
113 views

find: Why is the -a operator not commutative in combination with -print?

Supposing we're using find in current directory with audio files (e. g. MP3) and (important!) also non-mp3 files (e. g. JPEG) present in current directory or somewhere below it. Additionally to that, ...
1
vote
1answer
134 views

Apply recursive chmod to files or folders only

I'd like to apply chmods to files and folders in one line, Basically: chmod 700 ./* -R # but only apply to folders chmod 600 ./* -R # but only apply to files Of course I searched google and read ...
6
votes
2answers
406 views

When will `find . -exec COMMAND {} +` execute COMMAND multiple times?

If I do find . -exec echo {} + it prints all paths in one line, i.e. command echo is only executed once. But according to man find, -exec command {} + ... the number of invocations of the ...
5
votes
2answers
51 views

mv with rsync functionality

I'm trying to merge two directory trees that have many common elements but also each have elements that are only present in one of the two trees. The main issue I am having is that when mv encounters ...
0
votes
1answer
26 views

find file read it and search for specific identifier

I'm trying to find out in what files some specific identifiers are being used. I know the file's name and know the identifier, therefore I use the following command to achieve my desired result: find ...
4
votes
2answers
246 views

Can find work more efficiently to delete a large number of old files?

I want to delete old files in a directory that has a huge number of files in multiple subdirectories. I am trying to use the following - after some googling it seems to be the recommended and ...
1
vote
2answers
68 views

grep contents of files based on a list of files

Running CentOS 6.5, qemu-kvm. I have a script which builds a list of running VM's. I want to pull information from those .xml files of only the VM's that are running. cat /dev/null > ...
1
vote
2answers
46 views

Getting the size of parent folders when using find to search for criteria?

I am hunting for a certain regular expression within the filenames and am seeking to return the parent folders with their sizes in a unique fashion. For example, here is the command that I expected ...
1
vote
3answers
113 views

shell script for auto-touching files

I have written a shell script to touch all the files in the /tmp directory. However, there was an error message saying that /bin/touch: Argument list too long. What's the cause of the problem? ...
4
votes
2answers
72 views

Find all symlinks to a directory and change target to another directory

I have a bunch of symlinks in /home to files and sub-directories in /foo. I want to target the new directory, /bar. My approach was to look at all invalid symlinks and verify that they were pointing ...
1
vote
1answer
35 views

sliding window of JPGs from thousands of files

My machine has a camera attached that can take thousands of jpgs a day. I am looking for a way of remotely looking at the last 30 to 60 mins of footage via a cloud storage site such as box.com. I ...
4
votes
2answers
132 views

Why does 'find -delete ' delete all files in a directory recursively

So the following behaviour of unix find just cost me dearly: > touch foo > touch bar > ls bar foo > find . -name '*oo' -delete > ls bar > touch baz > ls bar baz > find . ...
2
votes
1answer
41 views

rolling snapshot of pictures taken in the last half hour

I've taken this: find -maxdepth 1 -mtime +1 -type f -exec cp '{}' backup \; Which should copy all the regular files in the current directory more than 1 day old to the directory backup (assuming ...
-4
votes
1answer
99 views

What command in bash to search for this string?

file.txt contains: aa=testing sss=whoiam bbb=findme What command do I use to search for testing and print it? Expected result: # you search testing
2
votes
1answer
33 views

How do I search files without certain extensions in their names?

I would like to search recursively in all the files and directories under a directory for some strings e.g. library. I also would like to exclude files and directories which store downloaded ...
2
votes
4answers
172 views

Execute all files in a list

I have a source tree which, when make is run, produces several executables named "001", "002", and etc. I'm trying to write a script which will find all of these executables in my source tree, and ...
1
vote
1answer
124 views

How to delete older files in a folder in unix?

Can anyone help me find the meaning of the below statement? I am new to Unix programming. find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ \;
0
votes
1answer
410 views

ls command - list files containg speccific string in file name and belong to specific type

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will ...
0
votes
4answers
71 views

Find a directory created today

How can I find a directory whose name starts with cy and that was created today?
3
votes
2answers
185 views

Why does find -exec du sum up differently?

I have family pictures and movies in a folder /media/data/Selbstgemacht and I'd like to find the size of all pictures. In /media/data I use find Selbstgemacht -type f -iname '*.jpg' -exec du -ch '{}' ...
-4
votes
1answer
40 views

What is the significance of the the leading “4” before the listing of modified files?

After running the following command: find /Users/UserName/Documents -type f -mtime -1 -print0 | xargs -0 du -sk | sort -nr I receive the following output: 4 ...
1
vote
2answers
99 views

With “find /”, skip directories like “/proc”, “/sys” and similar

There are some directories that can cause problem with find, and especially find /. These are directories in which the OS creates files which are not really files. Among these directories are /proc ...
3
votes
5answers
82 views

How to find and empty some directories

I'd like to find and delete the contents while leaving the directories themselves intact. The following find /data1 -name MyTargetDir -type d -exec rm -rv {} \; and find /data1 -name ...
6
votes
4answers
132 views

Find newest file. Multiple Filetype restrictions

I want to write a command that gives me the newest file in a directory recursively. But that's not my only limitation. The files has to be an mp3 or a jpg file. (case insensitive prefered) I only need ...
5
votes
2answers
76 views

Where does the pattern occur in a match by find?

The manpage of find says: -name Base of file name (the path with the leading directories removed) $ find ~ -name bookmark | less returns nothing, while $ find ~ ...
1
vote
4answers
121 views

Finding a file which created X minutes back (without GNU/BSD find)

I am using the find command to find the files which were created with in 30 minutes. find . -ctime -30m But it is giving files from up to 30 days. I have tried -mmin too but it is showing that ...
1
vote
2answers
76 views

How to determine the newly closed file within a continuous audit log rotation?

I am attempting to find the best way to determine when the second file (of a matching criteria) is created. The context is an audit log rotation. Given a directory where audit logs are created every ...
1
vote
1answer
77 views

How to specify file path with find when searching for files with -regex

I want to search a directory for some files using find and a regular expression. If I do cd dir find -E . -type f -regex '^\..*[^~]' I get a list of files in the directory that match the the ...
4
votes
3answers
422 views

Find a file which is 30 minutes old

How can I find the file which is of 30 minutes old in /bin/ksh?
4
votes
1answer
597 views

Find directories and files with permissions other than 775 / 664

I am moving a website from one server to another and Git does not store metadata such as file permissions. I need to find the directories and files that are not 775 / 664 respectively. Right now, I'm ...
4
votes
1answer
1k views

find files without extension

Let say I have: foo.txt bar baz.ooo If I use ls -1 !(*.*) then I'll get only bar on the output. Great, now I wish to have same results with find - some find -regex that will do the job. NOTE: ...
0
votes
3answers
68 views

cd to the most recently created directory [duplicate]

I have a directory in which a number of directories are created daily. I want to enter into the directory which is created recently whose name starts with cy. How can I find this directory? Could ...
3
votes
3answers
1k views

Moving latest files from one directory to another

I'm trying to move newest files from one directory to another directory. The find command finds the files but not moving them to another directory. The destination directory exists. $ cd ...
0
votes
3answers
179 views

find command: -or option doesn't work

I want to execute a command for an each file that matches a pattern. But the command that seems to be right, doesn't work for me, I have no idea why. $ find . -type f -name '*.c' -or -name '*.h' -or ...