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

learn more… | top users | synonyms

1
vote
2answers
43 views

finding latest date and date modified file and using sed

I have a series of files that contain a date and I need to get the file which has the latest date, and the latest date modification and pipe it to sed. I have tried various approaches and I cannot ...
0
votes
3answers
114 views

bash find using variable

I have an issue I don't understand. It is simple and it should work, but it doesn't. =EDITED exactly what I can see from terminal= I have a list of filenames: [molni@archlinux picasa_album]$ cat LIST ...
2
votes
1answer
34 views

how to execute a shell built-in if find found certain files

In general, if we want to execute a command if find identifies files corresponding to certain specs, we can use -exec. But in my case I want to exit the shell/script if find found a match and -exec ...
4
votes
5answers
150 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
28 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" ...
7
votes
1answer
280 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
41 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 ...
-2
votes
1answer
42 views

Delete empty directories without find

I want to delete empty directories without using find command like the following: Instead of find . -empty -type d -delete use if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi ...
1
vote
1answer
37 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
23 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
184 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
32 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
45 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
240 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
679 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
48 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
48 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
27 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
36 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
107 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
46 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
211 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 ...
4
votes
2answers
33 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
17 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
153 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
58 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
29 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
52 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
48 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
27 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
92 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
36 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
84 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
30 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
157 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
32 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
49 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
38 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
88 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
39 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 ...
0
votes
2answers
34 views

Skipping pseudo-directories with find /

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
76 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
119 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
72 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
70 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
54 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
47 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
115 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
186 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 ...
3
votes
1answer
239 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: ...