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

learn more… | top users | synonyms

1
vote
1answer
51 views

my permission command doesn't work properly

find . a* -exec chmod o+r {} \; find . *d -exec chmod o+x {} \; I want to give o+r to all files that start with "a" and o+x to all files that end with "d", but these lines seem to affect all files ...
1
vote
2answers
590 views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
1
vote
1answer
138 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 ...
1
vote
2answers
1k 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 ...
1
vote
1answer
830 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 ...
1
vote
2answers
160 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 > /<path&...
1
vote
2answers
159 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
2answers
2k views

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

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 /...
1
vote
1answer
979 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 ...
1
vote
1answer
469 views

Extract file name from find command

I am trying to extract the file name and attaching to mail. But when I send mail the attachment is coming with path name and file name. Ex: dir=/home/as123/bill and filename=abc.pdf.Z and I am ...
1
vote
1answer
113 views

Using a zsh function in find?

I'm on OS X and have defined a function called finderpackage that tries to determine if a folder is in fact a "package" (also, somewhat erroneously, known as a "bundle") according to the Finder. My ...
1
vote
1answer
4k 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' ...
1
vote
2answers
194 views

visit all directories under version control

Is there a find incantation that would allow me to visit all directories under SVN version control? I am trying to use the execdir switch to add to the svn:ignore property in each one of these ...
1
vote
2answers
177 views

How to find a symlink when the location in which it was created is unknown?

I followed some slightly incorrect instructions to install my video driver. I executed this command blindly and don't know what directory I did it: sudo ln -s lib /usr/lib64 How can I find that ...
1
vote
4answers
380 views

thoroughly find all links (hard and symlinks, and any combination thereof) leading to a file/dir [duplicate]

I read "most" of the proposed questions, but I believe they all miss the complexity of the right answer. I want, only using "basic" commands (for maximum portability) (i.e., something that would work ...
1
vote
3answers
5k views

Count number of lines with a certain value in a column for all files in directory recursively

I have 40 files in a directory and I want to count the number of times there is a line with a "2" in the first column in each file individually. I am trying something like this, but it prints out ...
1
vote
3answers
580 views

Using Shell Commands to Manipulate File Paths for Use as Arguments to Another Program

I can use find like this to find a list of files: find -type f -path "./src*" -name "*.php"` For example: ./src/Superuseradmin/Model/Mapper/UUID.php ./src/Superuseradmin/Model/Mapper/Mapper.php ...
1
vote
2answers
2k views

Delete n minutes old file in solaris

Can some one please tell me how to delete n minutes old files in Solaris? My find does not -mmin option.
1
vote
3answers
3k views

find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664; does not work

I am using this command to set permissions for files recursively clime@vm6879 /srv/www-php/steeltrading $ find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664 But after executing that command ...
1
vote
2answers
4k views

Find all directories, in which user has access to search and echo this directories in shell

I need to find all directories, in which user has access to search(command find) and echo this directories in shell. USER is read from ksh. for example: read user I know, if user want to use find ...
1
vote
1answer
683 views

Speeding a find rm command with test through parallelization

I want to recursively delete all files in directories and subdirectories with number of lines less than 10, and am currently using the following command find . -type f -name "*.txt" | while read; do ...
1
vote
1answer
455 views

Using find to find symlinks that point to a certain pattern of files

I have several directories that all have various symlinks in them. I want find (or another program) to find based on where the symlinks point to. For example this is how it currently works: └─(11:05:...
1
vote
2answers
45 views

Find a folder excluding one

I would like to find a folder not named "STDF", then archive them. find /a/b/c -mindepth 1 -maxdepth 1 ! -path "STDF" -exec /usr/bin/gzip '{}' \; The above command is not working. Can someone ...
1
vote
1answer
160 views

How to Relink these symlinks after moving the system?

I moved my filesystem and symlinks from Ubuntu 14.04 to 16.04 by using FAT32 memory card, which apparently broke those links; stopped using BitTorrentSync. Differential condition is that those links ...
1
vote
3answers
32 views

ln -s $SOURCE/* except - with find?

I want to do a symbolic link from all directories and files in the first node of $SOURCE to $HOME/Destination/. Pseudocode ln -s $SOURCE/* exceptThese $HOME/Destination/ Proposal find $HOME ! -...
1
vote
2answers
32 views

How to get all subfolder names consisting of uppercases only?

How to get the folders in a parent folder, the names of which are composed of A-Z, without lowercases, underscore, dot or any other things?
1
vote
1answer
18 views

Format for iname in Find operation

When using find what is the correct format to say "Find files that end in .jpg OR .png"? Is it as simple as using the | operator/character? find -iname "*.jpg|*.png"
1
vote
3answers
37 views

Script or command to list all top-level directories that contain sub-directories with modified files less than 30 days old

This is quite a unique one. I'm looking for a way to list all top-level directories in a folder that contain sub-directories with new or modified files less than 30 days old in them. We use a ...
1
vote
1answer
43 views

Printing the file with number of hardlinks

I can print the number of hardlinks to files in directory by using find . type f -printf "%f %n\n" but this will also print the hardlink not only original files: Example: file1 is an original ...
1
vote
1answer
24 views

How do I get a count of files in a directory (recursively) but exclude directories with a certain name

This is very similar to this question, but I need to take it a bit further. I'm using a synology drive and there are tons of @eaDir directories which I want to ignore (and the files in those ...
1
vote
1answer
43 views

Rewrite a find command that uses sed -i for AIX

I have a script that searches for a string and replaces it via the sed command. If that string contains special characters, the script will escape them (except for the slash because it's my current ...
1
vote
1answer
71 views

Check if the files in a specific directory have the proper extension?

I have created a script that will create a few directories and then organize other files from one directory by moving them into specific sub-directories based on their extension (i.e. .gif in media, ....
1
vote
1answer
48 views

Why does `find -size -1G` not find any files?

When I issue: find / \( -type f -size +10M \) -and \( -type f -size -1G \) I don't receive any results; however, when I type: find / \( -type f -size +10M \) -and \( -type f -size -1000M \) ...
1
vote
2answers
55 views

find all hard linked files between two directories

How do I find if any files among two or more directories are hard linked? In other words, do any files under two or more directories refer to the same file? Similar to How to find all hard links to ...
1
vote
2answers
65 views

Tar files starting with the same pattern

I have some log files named : 2016-02-10_03-52.log 2016-02-10_04-43.log 2016-02-10_02-13.log ... 2016-03-15_07-03.log 2016-03-15_09-08.log Basically the pattern is : YYYY-MM-DD_.log I would ...
1
vote
2answers
50 views

Why does Solaris 10 find / -exec sh -c “echo {}” \; print “{}” instead of filenames?

I do not generally use Solaris, but today I need to craft a find command to execute an operation on identified files using the shell. I am finding that the {} characters are not getting substituted ...
1
vote
3answers
62 views

Pipe pattern input to find command

I have a scenario where I am trying to find multiple files based on the output of another command. The command itself is ./libopt -d test . 2>&1 | sed -rn 's/Cannot find library \"(.*?)\"/\1/...
1
vote
2answers
53 views

How to allow spaces in directories when using find -exec together with basename?

I'm trying to find all the directories in a given path, and create soft links inside those directories into directories with the same names at another location. Many of the directories have spaces in ...
1
vote
1answer
108 views

How do I find files older than 1 days using mtime? [duplicate]

I'm trying to remove all files more than 1 days old.Before I execute a script to remove the files,I try to find the files using mtime. however, I face same problem with my command- My Current date is ...
1
vote
1answer
46 views

Delete files that do not contain “.zip” in their filename

I am trying to find and delete files that don't have ".zip" in it and is bigger than 1 Gig. I found the following command. Can someone explain to me what the following command is doing? /etc/home -...
1
vote
3answers
29 views

problem with find (shell script)

I want the files of a given directory and use the following script: echo "give name of directory: " read directory if [ -d "$directory" ] then echo "thanks again" else exit fi find /-type f $...
1
vote
3answers
85 views

Find Directory if Number of files is over X

Am wondering if someone can advise on the best way to do this. In my Web Dir is around 100 folders; each folder is a clientID. Within each ClientID folder is a Sub-Set of folders. In each subset ...
1
vote
1answer
72 views

Create file for every result of find command?

With this line of code I generate an output of every result. exec("find ics/ -mmin +3 -type f -name '*.pdx' -exec basename {} ';' > ./tmp/filename") How can I generate a file with dynamic file ...
1
vote
1answer
53 views

Zip subdirectories based on find, -exec

Here's what I would like to achieve: I have some directories, and subdirectories in them (which may have sub-subdirectories). In each subdirectory I want a zip file with contents of that particular ...
1
vote
2answers
111 views

Find works fine in command line, but won't work in script

I am trying to write a script on a Debian Jessie host. I am having an issue with trying to run the following command (with a twist) in a script: find ~/* -path ~/FileSniper* \ -prune -o \ -type f \( ...
1
vote
1answer
31 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...
1
vote
2answers
68 views

Internal expansion with the find command and wildcard character [duplicate]

I'm still learning the command line and I am having some trouble fully understanding the use of the wildcard within the find command. I'm working in the directory user/temp and use the find command ...
1
vote
2answers
64 views

Where is my downloaded file

I tried to install java runtime with the following commands su - cd /opt wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=...
1
vote
1answer
98 views

Recursively delete subdirectories not containing pattern on OSX

I am trying to delete all sub directories (and files inside) that do not contain one of two patterns in the directory name using Bash on OSX. I am trying to do this recursively - for a bunch of parent ...
1
vote
2answers
54 views

xargs repl_str doesn't expand second placeholder

I would like to rename some files and exclude others into a directory. I tried find . -mindepth 1 -maxdepth 1 ! -name 000-default.conf ! -name default-ssl.conf -print0 | xargs -0 -I {} sudo mv -- {} $...