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

learn more… | top users | synonyms

2
votes
2answers
22 views

Copy files with parent folder to a new directory

I want to copy some files and include their parent directory in the process. The current structure is similar to: /Module1/A/downloads/m13312/file.pdf /Module1/A/downloads/m17312/file.pdf ...
0
votes
1answer
34 views

help with remote file find/scp

I have a set of files on a remote sftp which I need to download to a server every day. sftp uses ssh keys to authenticate, so I created a ssh key and added to the remote server authorized folder. I'm ...
2
votes
1answer
23 views

Efficiently finding a file/directory based on keyword

I have a large directory tree of builds. Standard find search locates the file after a minute or two. I'd like it to be in a few seconds. I need to find a file named foo.tar.gz. The file can reside ...
2
votes
0answers
17 views

Why does find not match repeat / quantifier expressions with emacs regular expressions? [duplicate]

I have a file 'abcd' in my current dir. Using find -regex '\.\/[a-d]\{4\}' gets me no results. While the regex works fine in emacs itself. find, however, does find my file when I add -regextype ...
0
votes
2answers
52 views

Files greater than 1 GB and older than 6 months

I want to find files which are greater than 1 GB and older than 6 months in entire server. How to write a command for this?
1
vote
1answer
23 views

find with -exec eval of $0 [duplicate]

In the following command I would like to know why $0 was evaluated to the file found by find and not the echo command. $ find . -type f -perm -u=x -exec bash -c ' /bin/echo $0 is the name of the ...
0
votes
1answer
29 views

Unusual behavior of find command

Please look at following out commands and their output: $ cat /sys/class/graphics/fb0/virtual_size 1920,1080 $ file /sys/class/graphics/fb0/virtual_size /sys/class/graphics/fb0/virtual_size: ...
0
votes
0answers
22 views

How would you find just the files created by a specified user? [duplicate]

I'm trying to create a script that prompts a user within the terminal to enter a username. If the username exists then the script will display all the files created by the user, else display a error. ...
3
votes
2answers
128 views

Understanding find(1)'s -exec option (curly braces & plus sign)

Using the following command, could someone please explain what exactly is the purpose for the ending curly braces ({}) and plus sign (+)? And how would the command operate differently if they were ...
2
votes
3answers
48 views

Search a String in a directory- Get output without filename

I am executing the below command to display the lines which matches the pattern. find ./files/ -name "*.txt" -print0 | xargs -0 grep "5|20150507" And output is ...
3
votes
4answers
168 views

Overwriting files found by find?

I have a list of files -rw-rw-r-- 1 t t 24813 Oct 23 2002 fig8_21.gif -rw-rw-r-- 1 t t 2259 Oct 23 2002 fig8_21t.gif -rw-rw-r-- 1 t t 35331 Oct 23 2002 fig8_23.gif -rw-rw-r-- 1 t t 2610 Oct 23 ...
3
votes
4answers
46 views

Find the last occurence of a string in a given filetype in all subdirectories

I have multiple sub-directories each with different depths. I need to search for the last occurrence of a string in a specific filetype (say *.out). How can I accomplish this? I have tried: grep -r ...
2
votes
2answers
27 views

Assistance in how to display write only files for a user specified folder

I'm writing a script that allows a user to enter in a folder of there choice. Upon completion, the script will then search starting from the root for the folder and display all the files within that ...
2
votes
2answers
52 views

Find files created by a particular user

How would I go about discovering all of the files created by a particular user and display them to the screen? I've started a script that prompts the current user to enter the username of whom they ...
0
votes
1answer
90 views

How to prevent expansion

My script parameters on the mask and consist parameters for the find tool: $mopt=false case $1 in ... -m|--mask-file) if $mopt; then or="-o" fi ...
0
votes
2answers
51 views

Further questions about -path for find

From http://unix.stackexchange.com/a/81379/674 -path does not (re)define the start path. It refers to the combination of the start path and the relative path of the currently examined object. ...
0
votes
2answers
39 views

Find command returning wrong data [duplicate]

I am using this command to list all files that have been modified in the last day (or created) find ./ -mtime 1 -ls However it keeps returning files from 30th April when I am running the command ...
0
votes
2answers
45 views

find and list -R returning different number of files

I'm trying to create an array variable with a list of files to use in a small script, needing the full path to the file. Looking around I tried something like this: find /path/ -t f | grep ...
2
votes
2answers
74 views

List files recursively in Linux CLI with path relative to the current directory, max 250 char

I'm trying to list all the files with names no longer than 250 characters (including the directory it is part of, from the relative path my command is inside). I've seen a similar thread , but that ...
3
votes
7answers
121 views

find files based on name and moving them with renaming simultaneously

Consider I've directories named according to years and containing pdf files according to subject-code. ls output is: $ ls -l total 32 drwxrwxrwx 1 root root 4096 Apr 8 08:52 May-June-2011 ...
2
votes
2answers
63 views

How to restore a folder that seemingly disappeared after using mv?

I moved/renamed a folder with .svg-figures using mv fig figs. In my mind, this should have renamed the folder 'fig' to 'figs'. Accordingly, the output from ls showed a folder named 'figs' when I ran ...
0
votes
1answer
24 views

Can't find the location of DUMPed file system

I dumped a file system, chose the name for the dump ("home_fs_dump"), the dump was declared successfull, and yet I couldn't locate this name anywhere in the system. (And at the end I tested if locate ...
1
vote
1answer
34 views

Unzip specific files from multiple zip files

I'm new to Unix and am trying to extract specific pattern filename from the multiple zip files. I'm using find to find the zip files, and then trying to extract files having the filename CTL in the ...
2
votes
1answer
42 views

make find fail when nothing was found

When find is invoked to find nothing, it still exits with code 0. Is there a way to make it return an exit code indicating failure when no file was found?
3
votes
1answer
24 views

Does find -links count the hard links or symbolic links?

Does find -links count the hard links or symbolic links ? find -links 2
12
votes
6answers
1k views

What is the difference between find . and find . -print

What is the difference between: find . and find . -print What does -print actually do? $ find . . ./hello.txt ./hello ./hello/txt ./hello/hello2 ./hello/hello2/hello3 ./hello/hello2/hello3/txt ...
1
vote
5answers
62 views

Difference between 'ls -ltr abc*' and 'find ./ -name abc*' command? [duplicate]

To search a file in a directory, I found two commands as below: ls -ltr initialfilename* find ./ -name initialfilename* Sometime, first command gives me the search result but sometime I used to ...
0
votes
1answer
24 views

find returns weird file order on RHEL but not on OSX [duplicate]

When I enter find . -iname "[0-9]*.nii" on my OSX machine it returns: ./03_Rest_fcMRI/9793_01_03_1.nii ./04_VEMP/9793_01_04_1.nii ./04_VEMP/9793_01_04_2.nii ./05_Tapping/9793_01_05_1.nii ...
1
vote
3answers
57 views

How do I create a copy of a file in multiple directories?

I have a folder structure conf/ widget1/ env1.cfg env2.cfg widget2/ env1.cfg env2.cfg widget3/ env1.cfg env2.cfg widget4/ ...
3
votes
1answer
48 views

`find` multiple -o -name condition AND ! -name

I'd been playing with this snippet and seems like I can't make my desired find work. I tried google but all tutorials does not seem to tackle this scenario suppose i have the following files ...
5
votes
4answers
257 views

Converting `for file in` to `find` so that my script can apply recursively

I've been working on my first bash script for some time now (I just started UNIX this week). I have this idea of running a bash script to check some conditions and using ffmpeg to convert all the ...
0
votes
1answer
40 views

find all directories (except `encoded`) in the working dir then delete all of them

I am trying to test this scenario, I have these files /encoded encode <~~~ a bash script /dir1 /dir2 .../dir2-sub test.meta what I wish is, for find to search for all directories in our current ...
0
votes
1answer
45 views

Why does “find / -path '/a/b/c” scan the whole / (root)?

Why does find / -path '/absolute/path/to/some*file' scan the whole root (/), including files in /proc, /bin and others? I usually get these errors: find: `/proc/tty/driver': Permission denied find: ...
2
votes
1answer
35 views

Skipping pseudo-filesystems when doing find/exec

Let me be clear about this. I want to do a find over multiple filesystems. What I wish to do is skip pseudo-filesystems. Other than -prune, is there a way to do this?
4
votes
1answer
45 views

Find the files between two folder dates in linux?

I need to find the folder names along with the file names which has my string in their contents. I am in this directory "/data/queue/data" and I have lot of folders in the same directory and inside ...
1
vote
1answer
41 views

List all regular files containing (in their name, directory or their content) a specific (sub)string

Like in the title, and also I want to print the number of the line in each (text) file where the substring occurs. So far I have: find /sys | grep "filesystem" But it appears to only look at the ...
4
votes
3answers
98 views

bash: error handling on find -exec

I was using this little script to find malformed images: find -name '*.jpg' -exec identify -format "%f\n" {} \; 2>errors.txt It worked well enough, but now I need to modify it slightly. Instead ...
28
votes
2answers
808 views

find(1): how is the star wildcard implemented for it to fail on some filenames?

In a file system where filenames are in UTF-8, I have a file with a faulty name; it is displayed as: D�sinstaller, actual name according to zsh: D$'\351'sinstaller, Latin1 for Désinstaller, itself a ...
0
votes
1answer
101 views

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
0
votes
0answers
11 views

Result of find in multiple columns [duplicate]

I frequently use find and often the results scroll up the screen while a sizable portion of screen is unused. Is it possible to get the results of find in two or more columns, similar to those of ...
1
vote
1answer
48 views

Find only in directories n levels deep

I use this command to find and run all istances of wp-cron.php I have for each site I have: find /var/www/ -name 'wp-cron.php' -exec php -q "{}" \; Since my websites tree is: ...
2
votes
1answer
72 views

Using find and sed to copy 20th line of many files into one file

I have a folder called "PKA1" Within this folder I have several folders that look as: 1eV, 2eV .... 30eV Within each of these I have subfolders I have a file called PKA.dump I want to copy the ...
0
votes
2answers
87 views

Recursively remove files with idx > 10,000

The problem In the current working directory I have several (very many) folders and some of them have lots (like 100,000+) of files inside. My goal is getting just the folder with 10,000+ files and ...
3
votes
3answers
70 views

Use for loop in find exec

-> find .. -name bin -exec for file in {}/* ; do echo $file ; done \; -bash: syntax error near unexpected token `do' What is the proper syntax for this command ?
1
vote
2answers
98 views

grep or find a pattern in all directories [duplicate]

I have an account number 1234-5678, I am trying to find it in all files of directories. I used the below command but no result found. grep "1234-5678" */ Please can someone help me how to find it in ...
2
votes
2answers
55 views

Is there `find`'s `-exec` like option in `ack-grep`?

I want to remove all texts that include string foo. I can list all files by ack-grep foo, but I couldn't find a way to remove all files like -exec rm {} option like find. How can I delete all files ...
1
vote
1answer
37 views

How to exclude the folders proc and sys from search with find command ?

I wanted to execute a script that picks out a random directory path: find / -type d | shuf -n1 Unfortunately I get error messages about the prohibition of entering certain directories. How can I ...
1
vote
1answer
41 views

How to interactively remove all directories matching given criteria?

My script below has two problems: The script stops after first matched directory rm -i is not quite interactive What are my incorrect assumptions that make it fail? How can I fix it? ls -1A | ...
0
votes
2answers
52 views

Rsyncing files from server to local machine automatically

I currently have a crontab job running on my machine every friday at 3 AM as a back up method. The job runs a bash script which runs an rsync command to sync files from the server to my external hard ...
-1
votes
1answer
28 views

Copy files from find command [closed]

I am trying to copy all *file.log files found using find. The problem is all files are named the same and it is only copying over one file. I need to find a way to rename the files in the command or ...