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

learn more… | top users | synonyms

2
votes
3answers
27 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
28 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
32 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
17 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
33 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
26 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
22 views

Copy files from find command [on hold]

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 ...
5
votes
2answers
139 views

How can I list files of which no symlinks exist?

I have a large "myfiles"directory full of miscellanous documents and do not want to modify its structure. I therefore created (several) other directories for each class of documents. For example I ...
1
vote
2answers
47 views

How to list only the last line of each directory?

I learned thanks to you, how to display only the last line of a listing,e.g. ls -ltr | sed '$!d' Now I thought, how to combine it with the find command, in order to repeat this onto each directory ...
5
votes
6answers
73 views

Exclude directories with locate search

A search with locate finds paths in the filesystem. Often, you know a priori you are interested in either files only, or directories only. A 'locate' search often returns many results. It would be ...
2
votes
3answers
129 views

find and grep pipeline returning nothing

I have files named lect1.txt, lect2.doc, and lect3.doc. I want to get a file which is a .txt file, and contains lect as the filename. I tried find *.txt | grep lect* and it returned nothing. ...
1
vote
0answers
34 views

ls or find option to exclude binary files

How can I list only files that aren't compiled code in the current directory? I'm reviewing the custom scripts and code on several HPUX and Linux servers before transferring them to a newer system. ...
0
votes
1answer
181 views

How to find all JPG files on the file system when .jpg extension is not obligatory ? [duplicate]

First thing I noticed when switched from Windows to Linux was, that Linux has no strict naming convention and no obligatory file name extensions like .bmp, .jpg, .exe etc. Therefore I can not tell by ...
0
votes
1answer
41 views

Search a file for a string in multiple directories

Can someone please help me with a command to search a file for a string in multiple directories? I am searching for the VIP in httpd.conf in multiple httpd instances. I am using: find ./ -name ...
1
vote
3answers
78 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 ...
0
votes
1answer
12 views

Makes it a difference whether I use a different -n flag value for xargs in combination with find command ?

Assume, someone searches for files that match some criteria using the find command and pipes the result into the rm command. find / -type f -name "*.jpg" | xargs rm First, I am not sure if the ...
2
votes
3answers
20 views

list all symbolic links to valid directories only with find

I can use find /search/location -type l to list all symbolic links inside /search/location. How do I limit the output of find to symbolic links that refer to a valid directory, and exclude both, ...
2
votes
4answers
118 views

How do I perform xargs grep on grep output that has spaces?

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
1
vote
1answer
34 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. ...
0
votes
2answers
27 views

Find a file and execute a command in the file's directory

I am trying to use find so it would find a script file and if found execute it in the same directory it found it in. Something like this: find . -name "CLEAN" -execdir "CLEAN" {} \; except {} is ...
1
vote
2answers
38 views

find files with path of a directory exclude subdirectories

How can I use find to traverse a directory, but not recurse into its subdirectories? I tried -prune and it does not work. And there is no -maxdepth option. find /opt/projectname/bin -type f ...
2
votes
4answers
62 views

Find and move with exclude

I need to use find and mv together requirement : Need to find all file *.xml but exclude deposit.xml and move it to another folder ( fairly simple) My attempt : mv `find ./*.xml '!' -type d | ...
2
votes
2answers
41 views

SED on Mac OS X

I'm using a MacBook Pro and I want to find and replace a given word with another with sed command, but it makes no changes. What is the problem? sed 's/\<cat\>/dog/g' tt.txt
6
votes
4answers
500 views

Can I use Find and Grep in one line

I am a complete novice in UNIX and desperately need some help. I have a directory structure based on events. In these events I have one type of file which does or does not contain a pattern for ...
1
vote
1answer
85 views

How to delete remaining files of removed user?

I know deleting user with userdel username can cause information leakage and other security issues (as tutorial book says, administrator should delete user with -r option). But i tried it to see what ...
2
votes
1answer
59 views

How to merge these commands into one?

This is what I am wanting to do: Convert a folder of HTML files into markdown, also copying over the the xml metadata of each of the HTML files by converting into YAML. I have done research and come ...
2
votes
2answers
100 views

Run a command with wildcards in each subdirectory

I use this command to make a montage of all the images in a directory: gmic *jpg -gimp_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0 -o -0000."$(date)".jpg I want to run this ...
0
votes
1answer
26 views

Find a file that doesn't include specific characters

I want to find a specific file that doesn't start with a,k,G or Q and in which the third letter in the name is not a digit. I have tried many links, but found nothing regarding to this composite ...
1
vote
2answers
27 views

Rsync “finds” files that are implicitly excluded

I have a semi-working rsynccommand that I have combined with the find command on a linux box to do a simple file transfer of a specific type and date. Here's the command: rsync -avx --timeout=30 ...
0
votes
1answer
18 views

How would I find any symlinks on my system that reference “/tmp”?

I need to create a list of all symlinks that reference the /tmp directory. How many are there in total?
0
votes
0answers
28 views

Is there a `find` command that uses a database, like `locate`?

locate is simple yet quick because it's database based. find offers much more options but it's slower because it actually browses the filesystem each time it's invoked. So.. find using a database ...
3
votes
3answers
40 views

Find command: multiple conditions

As a standard for my file/dir naming I use something like putting date and tags string into the file name separated by underscore, eg: 2015_03_10_usa_nyc_vacations_album_pictures For a long time I ...
2
votes
1answer
45 views

Push onto array with find exec

I want to iterate over all the files found by find and add each one to an array. Here's what I have so far: myarray=() find . -name '*.php' -exec myarray\+=\({}\) \; echo "${myarray[@]}" Instead, ...
1
vote
1answer
36 views

Find all the modified svn files and copy files modified in the same folder structure

I get all the modified svn files using svn st | grep ^M command M student/includes/class_student_promotion.php M student/includes/class_student_report.php M ...
0
votes
1answer
22 views

find files with two types of extensions last modified over 30 days ago

I want to find all the files in a directory that have not been modified for at least 30 days and end in .xml or .out. This is my attempt to cobble together a couple of references to build the right ...
0
votes
1answer
32 views

Find and convert all ALAC files to mp3 / opus / aac

I'm looking for a way to convert all alac files in a directory recursively to another format. Problem: alac as well as aac use suffix m4a, so find -name "*.m4a" doesn't work.
1
vote
0answers
19 views

What is SELinux's regex type?

I'm trying to locate all files on my system matching an SELinux file context (fcontext). These contexts are specified using some regex, and I'd like to use find -regex ... to the same effect. However, ...
1
vote
2answers
130 views

Does change of a file in a directory not change the time of the directory?

I want to find a file which I created recently, but I don't remember anything and can only guess it is under a directory indirectly with any possible depth. I inspected the times of all the ...
1
vote
2answers
29 views

query all symbolic links to a directory

HP-UX ***B.11.31 U ia64 ***** unlimited-user license. $ ls -al 10 May 9 2011 HORCM -> /opt/HORCM 8 May 9 2011 bin -> /usr/bin 0 Mar 29 2012 core Feb 18 05:36 dev How do I list the link ...
1
vote
1answer
50 views

if command in find -exec

I was just trying to list all directories and files under current directory and also write if they are file or directory with the following command: find -exec echo `echo {} : ;if [ -f {} ]; then ...
1
vote
2answers
50 views

How do I find folders containing no recently modified files?

I have a directory that gets a lot of data dumped into it, and I want to find all directories whose contents haven't been modified recently (e.g., in the last 5 days). I'm trying to compose a call to ...
3
votes
0answers
38 views

find printf switch POSIX alternative

I'd like to rewrite these 2 command so they will use only POSIX-complaint switches: find "$TARGET_DIR" -maxdepth 1 -type d -printf '(DIR) %f\n' find "$TARGET_DIR" -maxdepth 1 -type f -printf '%s %f ...
1
vote
3answers
51 views

Find files based on modified date(specifying the exact hour) [duplicate]

My question is: How to find files that has been modified from a given date(specifying the exact hour) to another given date(specifying the exact hour) in a given directory, from / for example. I ...
3
votes
2answers
111 views

How to list only JPEG files from root below using the command line?

I am searching for a method to find only JPEG files/ With my limited knowledge of Linux I came to this point: list all paths that exist from root below with find / pipe the result into next command ...
6
votes
3answers
153 views

What do the “features enabled” in GNU find mean?

When I use find --version with GNU find, I get something like this: find (GNU findutils) 4.5.9 [license text] Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) ...
2
votes
2answers
119 views

Using find to list all files under certain directory

I'm trying to use a single line command that will find every directory (or sub-directory) named bin and will then print a list of all the files under it, but will not also list the directory names ...
0
votes
2answers
41 views

find {} returns the full filename but I just want the filename without the extension, so index.md would return index instead of index.md [duplicate]

So I have find . -name \*.md -type f -exec pandoc --filter ./filter1.py -o {}.html {} And notice the {}.html. The {} returns a filename ending with .md, but I want it to just return the filename ...
5
votes
3answers
304 views

How do I move all the files with the same name scattered through the file system into one folder?

I have a file system tree and on different locations within it are files with the same name. I tried the following command on the command line: find / -name "HAHA" -exec mv {} /home \; It only ...
0
votes
2answers
33 views

how do I find the location of mysql drivers on CentOS 7?

MariaDB is installed on a remote CentOS 7 server. How can I find the location of the nearest equivalent to mysql-connector-java-5.0.8.jar in the server's file system? grep seems to only search ...
2
votes
2answers
49 views

Find and rm command not obeying exclude list occassionally

I am running a find and rm -rf directory list modified earlier than 7 days with an exclusion list of directories which should not be deleted at any case. This is the script excerpt find ...