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

learn more… | top users | synonyms

3
votes
5answers
168 views

delete folders older than 1 day

I want to delete all the folders that are older than 1 day with following command: find /test -mmin +1440 | xargs rm -rf But the output of find lists /test (and would remove it accordingly). How ...
3
votes
1answer
145 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
0
votes
1answer
30 views

find delete shows “No such file or directory”

I just run a command to "find and delete files & folder older than 100 days" on a folder, and got the following: $ find . * -mtime +100 -delete find: May_01_2015: No such file or directory find: ...
1
vote
2answers
47 views

find path directory in sub directory

I want to find the path for directory name bbb where the parent directory called aaa For example /aaa/bbb /tmp/aaa/bbb /usr/bin/aaa/bbb /home/aaa/bbb /home/aaa/xxx/bbb So i wrote something like ...
3
votes
1answer
23 views

Executing awk on each file found with find, then redirecting the result to a new filename

I am trying to take the results from find and then execute awk to print the first two columns. Then I want to redirect those results to a new file name for each file, using the existing file name with ...
2
votes
2answers
55 views

How can I turn `file` tool into a predicate for `find`?

I have something like: find . -type f -print0 | xargs -0 file | grep Matroska | cut -d: -f 1-1 | xargs rm I want something like: find . -type -f -filemagic "Matroska" -delete
0
votes
4answers
38 views

Clearing the content of files by size

Considering if I list files in a directory: drwx--x--x 43 root wheel 4.0K Aug 18 12:52 .. -rw------- 1 root root 268K Aug 18 04:31 build_locale_databases_log -rw------- 1 root root 5.2M Aug 18 ...
4
votes
3answers
26 views

How to search with GNU find for several file types at a time?

How is it possible to use the GNU find command to match several file types at a time (one search command)? The man page says: -type c File is of type c: b block (buffered) special c ...
0
votes
3answers
61 views

find command behaviour inside for loop

I have following part of code inside bash script. for dir in $(find /etc/aaa -type d -maxdepth 1) do #my code done #my code if /etc/aaa directory is not present then i want to exit script with ...
2
votes
1answer
30 views

Find | parallel executing script with path from find + other arguments

Due to my lack of Bash knowledge I've tried for a few hours now to get something like this to work: find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {Found Directory} {1} ...
4
votes
2answers
259 views

How can I find files with permissions greater than xxx but ignore files with SUID and SGID

I'm trying to find files with permissions that exceed 755. Using the solution from another post here I have been able to get mostly what I want: find /bin -type f -perm -755 ! -perm 755 This does ...
4
votes
3answers
70 views

How to remove space in all sub directories in shell script?

I tried following shell script to remove all spaces with underscores: find $1 -depth -name "* *" -print0 | \ while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done If I have a directory ...
7
votes
2answers
528 views

How to replace spaces in all file names with underscore in Linux using shell script?

I tried following shell script which should replace spaces from all xml files for xml_file in $(find $1 -name "* .xml" -type f); do echo "removing spaces from XML file:" $xml_file mv "$xml_file" ...
5
votes
1answer
45 views

Exclude directory in (native Solaris) find command

I'm trying to exclude the directory /zones in my find command. I don't have GNU find available, just the native Solaris find. I tried something like this: find / -type d ! -name zones The problem ...
1
vote
1answer
12 views

copy files with md5-based target name using find and xargs

I have a directory tree with many .dat files, where many of them contain special characters. They are used by another process which is only able to process files containing ascii characters. My idea ...
0
votes
1answer
21 views

How to pull one day old data from remote server to local server?

From what I have searched till now I only found command to PUSH one day old data from local server to remoteServer but what I want is to PULL one day old data from remoteServer to localServer. I ...
1
vote
1answer
22 views

List folders greater than 10G and mail to respective owners about the usage

In our environment, we have an NFS mount which contains all users home directories. I want to find the users who's home directories sizes are greater than 10G and need to send a notification to them. ...
2
votes
1answer
32 views

Cp files into subdirectory with find -exec

Why is this command not copying the 17 .png files into a sub-directory within my current directory? $ find . -maxdepth 1 -mtime -3 | wc -l 17 $ find . -maxdepth 1 -mtime -3 -print0 | grep -z loader ...
1
vote
1answer
65 views

POSIX-compliant recursive grep with no errors for inaccessible directories

What script would allow me to grep a keyword and print the filename containing the keyword inside the file content , for example 'Carhart' inside all .sas files in all subdirectories, I tried ...
2
votes
3answers
196 views

How can I exclude all “permission denied” messages from “find” in Solaris

Hi previous questions on this topic contain answers for Linux but does not work for Solaris 10. find . ! -readable -prune Does not work in solaris since -readable is not POSIX. What is the POSIX ...
1
vote
2answers
24 views

How can I list files by class/indicator (as in ls --classify) then by name?

ls --clasify append indicator (one of */=>@|) to entries. I would like to group the entries of the same class/indicator together. I can only find ls --group-directories-first for grouping the / ...
1
vote
1answer
29 views

Add arguments to last invocation of `find … -exec $COMMAND {} +`

I'm generation ctags using something like following line find -iname '*.[hc]' -exec ctags -a --sort=no {} + Consequence is, that tags are not sorted. For that I'm using sort -u -o tags tags What ...
3
votes
2answers
76 views

How to alias part of expression for find?

I prefer regular expressions with -regex over the shell pattern syntax of -name. I also want to use the posix-egrep type, so I'd like to do something like alias find="find -regextype posix-egrep" ...
0
votes
2answers
30 views

How could I run -exec on find command after | grep

I am on a remote machine attempting to move all loader.gif files into a /Pictures folder find . -iname *.gif | grep loader shows four file I would like to move, naturally I tried: find . -iname *.gif ...
2
votes
1answer
57 views

How to use regex inside exec with find?

Is it possible to use regular expressions based on the result (file name) inside the exec argument with find? I want to be able to "exec" based on parts of the argument, like: find . -name pattern ...
4
votes
1answer
71 views

How do I find a file name that's exactly 8 levels deep?

I'm using the 'find' command to search for files in a backup system. I want to find all file names containing a certain string (e.g. 'XYZ') that are exactly 8 levels deep. Is there a find syntax that ...
1
vote
2answers
27 views

Find and move directory to a new directory based on name [duplicate]

I would like to move all the folders contained in the folder "/example" named e.g. "*_jony" to a new directory call "/jony". I have try several way without success! It would be great to have some ...
0
votes
2answers
53 views

How to find all .zip and .rar files recursively and sort them by size [duplicate]

I am looking for all .zip and .rar files in comp_tuts folder and I am intersted in showing their file sizes and sorting them from biggest to smallest. I have tried ls -R *.zip ls: cannot access ...
0
votes
1answer
45 views

Find part of String and replace entire string in a file

I have a file named A.xml which contains a strings such as "Ticket_Release1" and "Ticket_V2". I want to find and replace all the strings in the file starting with Ticket_ with something called ...
0
votes
1answer
56 views

find files in a folder

I'm trying to make a FIFO script that keeps deleting files when disk usages reaches a limit. I have used the find command so that number of files wont be a limit to run the script. But I get an error ...
0
votes
1answer
74 views

How can I find and replace only in a range of columns?

I have a text file with 9267 lines. I want to find "A" with 5 spaces after it and replace it with "A" with 5 spaces before and after it on all lines, but only between columns 67 and 88. Text outside ...
1
vote
1answer
35 views

How do I find directories where none of the files inside have been accessed in a year?

I have a tools directory /tools/tool_name that has hundreds of releases of the tool inside. I am trying to find an easy way of knowing what releases can be archived. Is there an easy way of finding ...
2
votes
5answers
430 views

How to grep all xml files that do not begin with “<”

How can I find all xml files in the current directory and all sub directories, that do not start with < in the first line. I have tried this, but the grep doesn't work: find . -type f -name ...
0
votes
5answers
92 views

List only the count of all files/directories for the directory tree of present directory

I want to list the number of directories under each subdirectory tree of the present directory. As there are too many directories, I can't go into individual directory and check. Something like the ...
3
votes
2answers
131 views

rm not deleting file, thinks its a directory

I have a hard drive with windows loaded on it hooked up to my Linux machine for backing up some of the information. I want to delete one of the 'temporary internet files' folders and it deleted all ...
1
vote
3answers
39 views

To Rsync files where permission denied

I want to find those files which I cannot copy to another location such that I could do Rsync. I have an external HDD and my system´s HDD. The external HDD has files which my system is missing. I ...
0
votes
3answers
31 views

Excluding a folder from deleting empty files with find

I usually delete empty files and folders in my home directory with find using the following command: find /home/tjuh -empty -delete However I would like to exlcude one folder, namely ...
1
vote
1answer
44 views

What does this find error mean: “find: stat() error /hgfs: Operation not applicable”?

When I use the find command on Solaris 10, I get the following error message: find: stat() error /hgfs: Operation not applicable What does this error mean? NOTE: the output from mount: $ mount -v ...
-2
votes
1answer
37 views

Explanation of % directives in find -printf

find /tmp -printf '%s %p\n' |sort -n -r | head This command is working fine but what are the %s %p options used here? Are there any other options that can be used?
0
votes
4answers
62 views

Copying Only Directories With Files

I am trying to copy files and the directory it is in to another location. I can find the path like this: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-10 which outputs ...
0
votes
2answers
75 views

How to find manually installed program in Linux Mint

Yesterday I installed Android Studio. I didn't install via the package manager or Software Center. Instead, I downloaded the ZIP package and installed it. After the installation, Android Studio worked ...
0
votes
1answer
52 views

“find” function still print files I've already removed

I've removed some directories and files inside them using sudo rm and sudo rmdir, but when I execute sudo find /*/*/ng* the files I've previously deleted are still showing up, anybody know why and ...
0
votes
0answers
46 views

Help with Find function in Linux

I searched around and couldnt find this so sorry if it's another duplicate. Using Kali linux I am to find a file who is owned by user bandit7, owned by group bandit6 and is 33 bytes in size. However, ...
0
votes
2answers
62 views

How to find file without knowing the name of it [duplicate]

So I've finally given up after searching/trial and error for an hour now on how to find a file given specific criteria (none of which is the name of the file or the extension). The file info provided ...
1
vote
2answers
37 views

Script to Compare the “file size” with “last name of file” and if unmatched delete the file

In my environment, we'll be receiving files from clients into our Sftp. Sftp process the files, and move it to another tool, by appending the file size at the end of the file name. For example, ...
0
votes
1answer
30 views

Command to delete directories whose contents are less than a given size

I'm working in a directory ~/foo which has subdirectories ~/foo/alpha ~/foo/beta ~/foo/epsilon ~/foo/gamma I would like to issue a command that checks the total size under each "level 1" ...
3
votes
1answer
145 views

custom delimiter for unix find results

I want to use find to find some files, and return all files as a single line (without newline characters), and a custom delimiter between the files. So for example the result for three files would be ...
9
votes
1answer
263 views

How is updatedb so much faster than find?

How is updatedb so much faster than find? Here's a timed comparison between updatedb and a find command that does a seemingly similar task. compare.sh #!/usr/bin/env bash cmd="sudo updatedb" echo ...
0
votes
1answer
52 views

find returns 'No such file or directory'

Continuously getting so many warnings yet my command is working fine. find: `api/PlayersImpl0.smali': No such file or directory find: `api/PlayersImpl1.smali': No such file or directory find: ...
0
votes
1answer
33 views

Want to use find with rsync in script

I'm trying to make a script that will run in cron, that will search a path for specific file name. In the path there might be more folders with that same file name. If found and they are newer than 2 ...