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

learn more… | top users | synonyms

1
vote
2answers
27 views

Find doesn't work with recursion?

I ran the command below and notice it will only did the mod on the first level(SubDir*) on the finding and not the subsequence (ChildSubDir*). I wanted to ask if it is possible to go recursion on the ...
1
vote
2answers
28 views

Find file type reverse

On my image folder i want only images,so i will find all video files "intruders" using this command(found somewhere on stackexchange) find folder/imageonly -type f -exec file -N -i -- {} + |sed -n '...
1
vote
1answer
49 views

find: missing argument to « -ok » [closed]

A while ago, I ran chmod to change some file permissions to 777. A friend of mine told me to never chmod 777, so I decided to change the permissions again. So, first I looked for all the 777 files: ...
1
vote
3answers
108 views

How to find empty directories in unix [duplicate]

I want to show all the empty directories under my home directory, using shell script, can you help me find the code? (without using find's -empty)
1
vote
1answer
64 views

How do I combine '-size` and '-exec rm' in find?

When I use this, it works: find /home -name "error_log" -exec rm -rf {} \; But when I try to add a file size limit, it won't remove any files: find /home -size +5000000b -name "error_log" -exec rm ...
1
vote
2answers
101 views

Using rename to remove '.orig' from file and add '_1' to basename

I'm using a script to make backups of files, and to avoid overwriting files I've used cp --backup. Which leaves me with a number of files that look like example.mov.orig and test.mov.orig. I cannot ...
1
vote
3answers
166 views

Combination of find and grep command with exec option

I am trying to find all files inside /lib /lib64 folders that contain "lib" in their names and print that file names without extensions (.so or similar), avoiding identical names in output. My way is:...
1
vote
2answers
147 views

Issue when I try passing parameters to find command?

Parameter: export exc_lst='! -path "/var/app/s2/pnl/incoming/recondata/*.*"'; When I try using the below find commands: find $FILE_DIR -name "*.*" "${exc_lst}" -type f -mtime +20 -user sh79790 -...
1
vote
3answers
242 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 ...
1
vote
1answer
231 views

Using find -perm to find setuid files

I want to find list of all suid binaries. I use the command find / -perm 4000 However this does not give me any output. I understand that the SUID file may be in 4xxx permission mode. But if I ...
1
vote
2answers
53 views

How to find file that has read permissions from root directory?

I am trying to find files with read permissions from root directory and save them under /home/student/abc direcory: find / -type f -perm a+r -exec cp /home/student/abc {} + but it shows me the ...
1
vote
2answers
38 views

Utilizing The 'find' Utility - Wrong Pattern?

I've been trying to find a particular shared object within ./lib/ using the 'find' utility in the bash shell. To be more specific, to find this shared object I wanted to find all files that started ...
1
vote
1answer
181 views

Trying to find all files in certain directory that are not referenced in other files

I have this project that has a images folder with images in them and I'm pretty sure some of them are not used. So I'd like to list all images that are not referenced in any other file. I'm not very ...
1
vote
2answers
214 views

Find file which name contains given substrings simultaneously

In general, it's often needed to find a file whose name should contain several substrings simultaneously. How do I do that with bash? For example, "boost", "qt" and "linux" in a file called "How to ...
1
vote
3answers
388 views

How can I replace string in all files in a directory and all sub-directories without changing any of the hidden directories/files?

I am using the following command find . -type f -exec sed -i 's/_backpack.html/_backpack_cal.html/g' {} + I expect all "_backpack.html" strings in my project to be replaced to _backpack_cal.html ...
1
vote
1answer
257 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 (...
1
vote
2answers
815 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 ...
1
vote
2answers
3k 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
3answers
2k views

Find result used in if statement

How can I use the result of a find command in an if statement and compare with true or false? Something like this: if [ `find . -name test.txt -size 156c`="true" ]; then echo Found; fi This is ...
1
vote
1answer
55 views

mv to file with

I ran the following mv command, apparently by mistake using backslashes by mistake instead of slashes. mv 2015-02-02_flyer_ppces.pdf ..\PPCES2015\2015-02-02_flyer_ppces.pdf The output is empty. ...
1
vote
3answers
1k views

Shell script to find and count total number of characters in all the files

How can I make a script that finds every file in your home directory that is less than 3 days old and then gets a count of the total number of characters in all of these files?
1
vote
1answer
165 views

Using Rsync in conjunction with Find

I'm am attempting to write a script that will copy files created in the last 24 hours AND be of a specific file-type (*.png). The command I have tried is: rsync -avz --ignore-existing --include='*...
1
vote
3answers
275 views

Find file by magic pattern maching

There is a bash command file(1) which outputs a file's contents type according to the matching pattern definitions in the /etc/magic and /usr/share/misc/magic. Is there a way to use these pattern ...
1
vote
3answers
544 views

Remove old directories according to directory's name?

In my bash script I create a directory each month for backups as follows: DAY=$(date -d "$D" '+%d') MONTH=$(date -d "$D" '+%m') YEAR=$(date -d "$D" '+%Y') mkdir -p /var/app/backup/$DAY$MONTH$YEAR ...
1
vote
2answers
2k views

Sort files according to their extensions

I have made a script that will sort files according to their extension and place them in the proper folder. For example, place abc.jpg in the directory jpg. #!/bin/bash #this script sorts files ...
1
vote
5answers
210 views

How to delete files, symbolic in one folder, but leave its subdirectories unchanged?

Assume there is a folder that has files, symbolic links, and subdirectories as following: files: file1, file2, file3, file4 symbolic links: link1-->file2, link2-->file3 subdirectories: dir1, ...
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
595 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
141 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
1answer
862 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
163 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
171 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
1k 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
486 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
115 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
5k 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
181 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
388 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
6k 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
587 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
691 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
460 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
49 views

Find files with pattern and get latest one

I want to find file with specific pattern and print the latest file matching the pattern with full path find ../*.gz -type f -print0 | sort -nr | cut -d: -f2- | head -n 1 How do I print the full ...
1
vote
2answers
42 views

How does the -name switch to GNU find work when targeting a directory and its contents?

I have a folder full of source files for an application, the project uses git for version control and so there is a .git directory: ├── composer.json ├── .git │   ├── branches │   ├── config │   ├── ...
1
vote
2answers
50 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 ...