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

learn more… | top users | synonyms

0
votes
1answer
66 views

Delete subfolder and keeping up parent folder

I need to delete folderx which are not accessed for seven days, easily I can do it with next: find /path/folder -type d -mtime +7 |xargs rm -rf The probelm is when I have subfolder marked for ...
2
votes
5answers
1k views

Find all files that have been last modified on a specific day - like Monday?

So I want to use find to return a list of all .html files in a given directory that have been last modified on a Monday. How can I do this?
4
votes
2answers
130 views

Find command returns wrong files

I'm trying to find files in a folder using find command which are a day older than the day on which the command is run.. I use the following command: FILES_dcn=($(find $dir_dcn -maxdepth 1 -type f ...
1
vote
3answers
313 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
2
votes
2answers
362 views

Symlink all subdirectories in a directory to another directory

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
6
votes
4answers
369 views

How to only zip the files of a specific user?

I like zip, it's simple, but recently I came with the need of only zipping the file owned by one user in a directory. I read the manual and I can't find any option to for example do things like: ...
6
votes
1answer
98 views

Expected behavior of `find -depth` if execute permission denied for subdirectory?

I'd like to know if I can rely on the behavior I am seeing when using find with -depth option and user does not have execute permission for a subdirectory. Assume the following directory structure: ...
3
votes
4answers
298 views

find -exec exit 1 \; Doesn't work neither does find -exec sh -c exit 1 \;

Using Enterprise Linux 5/6, Bash 4.x I want this type of logic: # IF temp file exists, exit because we are restarting already find /tmp/restarting_server -mmin -10 -exec exit 1 lsof -i TCP:1234 ...
19
votes
3answers
1k views

Find a file when you know its checksum?

I have the md5sum of a file and I don't know where it is on my system. Is there any easy option of find to identify a file based on its md5? Or do I need to develop a small script ? I'm working on ...
4
votes
3answers
440 views

Search for specified keywords in files and copy to a new filename based on the keyword

I'm trying to create an .sh script where if any keyword is found in a file then copy that file to the directory /pathtofolder/keywords/$thefirstkeywordfound (overwrite the file if it already exists). ...
3
votes
3answers
6k views

Why can't find -regex match a newline?

Why does this fail? touch "$(printf "a\nb")"; find . -regex './.\n.' I also tried these, none of which work: find . -regextype posix-extended -regex '.\n.' find . -regextype posix-awk -regex ...
2
votes
1answer
196 views

How to find files that contain newline in filename?

I am trying to find files that have a newline in the filename. But I can't figure out what pattern to use. The following works, but is not very useful if I want to use it in indented code. find . ...
3
votes
4answers
438 views

Use basename to parse a list of paths held in a file

I'm running Mac OSX and trying to use the command line to find the number of files I have with the same name. I tried to use the following command: find ~ -type f -name "*" -print | basename | sort ...
7
votes
2answers
579 views

Why “ls” doesnt show the file that “find” discovered ?

(New to unix) In ubuntu When I am up in "/" folder i type sudo find . -name .erlang.cookie and the result is ./var/lib/rabbitmq/.erlang.cookie then when I am on the folder - /var/lib/rabbitmq ...
0
votes
2answers
2k views

copy files modified after specific date using cp switches

When I execute the command find . -mtime -60 I get the list of files modified within the last 60 days. So when I execute find . -mtime -60 -exec cp {} /tmp/1 \; I can copy these files to a new ...
2
votes
2answers
31 views

Search for files by content only in trunk subdirectories

I think its a simple question, but the answer is probably a little more complicated :P Edit: Actually, its not complicated at all!^^ So I have a directory with multiple svn projects and I would like ...
1
vote
2answers
120 views

Emacs temp dot hash file don't exist

I use find | xargs grep a lot when working on large source code and when I didn't save a file in Emacs it creates .#SomeFile and grep give error that there's not such file (I'm not including because ...
2
votes
2answers
124 views

How to get directories and and subdirectories count fastest way?

I want to get the number of directories and sub directories.I tried following command which takes very long time . I tried waiting about an hour to finish the command. commands I used $ find . -type ...
1
vote
3answers
81 views

parsing file from ls -laLR

ls -laLR /home/tools > all_site1.txt I need the state of all folders and files in subfolders of /home/tools. With this command I put all in this file. What I need now is a solution how to parse ...
5
votes
3answers
2k views

Delete files and directories by their names. No such file or directory

I need to delete all compiled data: directories called build, directories called obj, *.so files. I wrote a command find \( -name build -o -name obj -o -name *.so \) -exec rm -rf {} \; that ...
12
votes
3answers
527 views

Two find commands comparison

Recently I received this find one-liner, but I'm not able to explain where the difference of the below two comes from: Example 1 [root@centos share]# find . -exec grep -i "madis" {} /dev/null \; ...
3
votes
2answers
77 views

How to find Emacs backup files?

Emacs backup files start with .# but I can find those in my directory. I've try: find . -name '^\.#.*' or find . -name '.*#.*' and they are not show up, and I have them. For instance if I create ...
0
votes
1answer
96 views

Lynx incremental search

I am trying to run an incremental search using lynx. Imagine a page, for example, an index_of page which contains several folders which also contain other subfolders and files. I want to run lynx in ...
-1
votes
4answers
94 views

Using 'find' to create text file, and later deleting files listed

I'm trying to use find to create a text file with the result. And then later be able to delete files, based on that list. I'm using find /volume1/video/ -iname "sample" to give me the results. How do ...
0
votes
1answer
28 views

Finding all kinds of extensions referenced in a html file

Here is my problem statement : There is a folder with many html and text files. I need to recursively go through each one of them and find all kinds of file extensions referenced in these html/text ...
6
votes
4answers
4k views

How to find a file in Linux with its path?

I am trying to find settings.xml file in my Ubuntu machine. I have no clue where it is, and which directory it is in. I tried using this - ls -R | grep settings.xml But it doesn't show me the ...
0
votes
2answers
150 views

Handling files with whitespace in their names

I have a lot of files that I need to sift through, specifically grep for certain keywords IN THE FILE, not he FILENAME. I have some 300+ files on a filesystem (so the files are within multiple ...
3
votes
3answers
450 views

Which command to use to find all files/folders with non-default permissions?

Suppose I have a folder, containing other files and folders, and I'd like to find out recursively which subfiles and subfolders have non-default permissions (i.e., not 644 or 755). Which command can ...
0
votes
2answers
146 views

Finding all .cpp and .h files and moving them to ~/junk

I created a folder on my home directory call junk, and let's say I want to move all .cpp and .h files to it. How would I do it? My first thought is to start with find ~ -name *.cpp -print, but I don't ...
1
vote
4answers
46 views

Find files on disk that match a really long text list of files

I have a list of tens of thousands of file names. I want to find which of those files actually exist on disk (in a particular directory). I'm not sure how to start. I could try it with either Python ...
1
vote
3answers
149 views

How to use the pipe command to open a directory after find?

Is there a way to opend found directories (via find) all in one command? One of the things I tried to study several times and never been able to really get, is the effective use of pipe: is it maybe ...
3
votes
1answer
79 views

-not -name does not work with find

I am trying to use find/grep to find some text patterns in my code base. I want to exclude non-source directories into which my build process duplicates source files: find . -name *.java -not -name ...
3
votes
1answer
226 views

find/grep outputs two lines for each file it finds match

I search my code base to find string patterns and list all the files where the pattern is found but only the file and not the lines on which it is found: find . -name *.java -exec grep -l 'someText' ...
4
votes
2answers
132 views

In Linux Fedora, How can I select files to move by time interval

How can I select and move files that were written in a specified time interval, such as 1530 to 1730 local time on a recent date? Background: I use Linux Fedora 12, and I have made my first, and long ...
1
vote
1answer
818 views

Basename gives extra operand error

I 'm using the following script to merge few pcap files into one using mergecap command. But when I run it it gives me a 'basename: extra operand /mnt/md0/capture/DCN/dcn_2014_02_04_00_11_47_598.pcap' ...
4
votes
3answers
373 views

Using find command to find folder ignoring case

I would like to know if a particular folder is present or not. I used the following command find /mnt/md0/ -maxdepth 1 -name 'dcn'||'DCN' I want to know if folder name is DCN or dcn . How would I ...
1
vote
2answers
331 views

Find duplicate file names with specific matching pattern

I have a folder with some files (snippet of the contents of the folder) PAT1.URGRSVP.50.WR786842JOB11632.WRS20140.FILE0005.DAT PAT1.URGRSVP.50.WR786842JOB11643.WRS20140.FILE0003.DAT ...
3
votes
2answers
2k views

Get list of subdirectories which contain a file matching a string

How can I get a list of the subdirectories which contain a file matching a particular string? More specifically, I am looking for directories which contain a file with the letter 'f' somewhere ...
0
votes
2answers
113 views

Deleting large number of files

I'm writing a script to delete large number of files in linux. The script will run every two minutes in crontab. I tried using the find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" ...
3
votes
2answers
566 views

Save find -exec output to text file

I have a set of videos in the folder. I would like to get the info about this videos using ffmpeg -i command and save the output to file. So I wrote the line: find . -type f -exec ffmpeg -i {} \; ...
2
votes
4answers
343 views

print parent directories full path of find output

what I want to do is to find all files based on some search query and get parents parent directory (../..) full path. For example find . -name "__openerp__.py" and then for each file execute ...
4
votes
2answers
447 views

Find files newer than another file within each subdirectory

I have a folder structure like this /Class/Student/Unit/files Each Unit folder contains a file MarkSheet* that I update when I mark a students work. I need a script that tests if the student has ...
-1
votes
4answers
114 views

Need a command sequence that will move files from one directory to another based on a particular year? [duplicate]

I'm looking for a sequence of commands (one liner would be ideal) which will identify all the files created in particular year, and move the resulting files to another directory.
3
votes
4answers
268 views

Using a generated list of filenames as argument list — with spaces

I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this: $ myscript `find . -name something.txt` The problem is that some of the pathnames ...
1
vote
1answer
51 views

find: prune does not ignore specified path

I need to exclude .git from my find search. To achive that, I am using the -path ./.git -prune switch: $ find . -path ./.git -prune -o \( -type f -o -type l -o -type d \) | grep '.git' ./.git ...
2
votes
1answer
262 views

Combining options in find command

Using the find command is there a way to combine options: i.e. find . -type fd -name "somefile" Although -type ignores the second option; I'm looking to find only files or directories.
9
votes
3answers
2k views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
0
votes
1answer
235 views

How to escape spaces while using command's output in command line [duplicate]

I want to perform the following command in command line : $ md5sum $(find . -type f) But this would cause problems when it encounter files with spaces in filenames : md5sum: Kaufmann: No such ...
2
votes
1answer
2k views

find + grep to match exact keywords in a file

My script is not matching exact words only. Example: 12312312Alachua21321 or Alachuas would match for Alachua. KEYWORDS=("Alachua" "Gainesville" "Hawthorne") IFS=$'\n' find . -size +1c -type f ! ...
2
votes
2answers
100 views

help with truncate \ find

This command won't work: $ truncate -s 0 $(find . -size +1c type -f -exec grep -LwE 'keyword1|keyword2|keyword3' {} +) "find: paths must precede expression: type Usage: find [-H] [-L] [-P] [-Olevel] ...