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

learn more… | top users | synonyms

2
votes
3answers
70 views

Using find with 2 sets of variables

I want to be able to run a find command in my bash script that will find files based on two seperate variables. I've gotten this far but I'm not sure how to get the final result workingfind . -user ...
1
vote
0answers
26 views

Using Rsync to SSH and Find files

Hello I am trying to use Rsync to SSH into a remote server and pull a certain type of file that has been modified within the last 24 hours. Here is what I am trying: rsync -avx --timeout=480 ...
1
vote
2answers
27 views

Using find and aspell together

I'm trying to spell check all the *.md files in my current directory but the following command fails: >> find . -maxdepth 1 -name "*.md" | xargs -I {} aspell check {} xargs: aspell: exited with ...
-1
votes
1answer
18 views

How to search for all SUID/SGID files?

All the howtos that I find on the web states: Find all SUID files: find / -perm -4000 -print Find all SGID files: find / -perm -2000 -print But that is not true. See: $ ls -lah test -r-sr-xr-x ...
1
vote
1answer
30 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 ...
2
votes
1answer
72 views

bash find: get directory of found file

I have a parent folder named "parent_folder" with a lot of subfolders, in these subfolders is a file named "foo.mp4". I can find these files easily by doing this: mymacbook:parent_folder username$ ...
-1
votes
1answer
23 views

Check exist file on another pc

Yesterday I had ask how to use my tftp protocol in my bash script: Debian - Using TFTP in a bash script And now I have a problem with my tftp protocol. The file who was taken depend of my Hostname. ...
1
vote
2answers
61 views

Multiple File Redirection with awk and find

I have some files in a directory. And I want to add some lines at top and end of file using awk. Example: My awk command: awk 'BEGIN { print "line1\nline2" } { print $0 } END { print "line3\nline4" ...
0
votes
2answers
25 views

How to make a script to move files with find and regex

Im trying to make a find regex script so i automaticly can copy files to specific directory. find . -regex "*test.*s01e([0-9][0-9]).*" -exec cp {} /storage/tv/test/s01/ \; Made this script, dont ...
1
vote
3answers
17 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 ...
4
votes
2answers
68 views

status check for sleep command

I have run sleep command in background as follow , How can I know the status of execution ..? Command sleep 2d ; find /home/disk1/ -exec touch {} \; & How can I know that its executed for 1 ...
0
votes
0answers
40 views

Why is the “move” word necessary when using find + xargs + rsync in this example? [duplicate]

I often use this sort of command on my Mac to transfer files remotely: find . -iname '*.txt' -print0 \ | xargs -0 -J % rsync -aP % user@ip:/foo/bar I had to perform this on Linux. Since GNU ...
5
votes
2answers
96 views

Create symlink tree in existing directories

I carry all of my music around on a 1TB USB drive and have a udev rule to symlink it to $HOME/Music/ when I plug it in to one of my laptops, which it does. The issue I have is that this works fine ...
1
vote
3answers
37 views

How to express all files/directories at the extra -exec option of `find` command?

I have a task to copy all files from multiple directories with special names to a target directory. So I build this directory to test my command. The test directory tree looks like: . ├── dir1 │   ...
5
votes
1answer
125 views

Why does 'find -exec cmd {} +' need to end in '{} +'?

Preface: I understand the difference between -exec {} \; & -exec {} +. I also don't have a problem as such, I am just curious about the semantics of find. When ending the -exec argument with + ...
2
votes
3answers
56 views

Print file name extension using -exec in find

I am playing around with -exec flag of find command. I am trying to use the flag to print the extension name of files, using a fairly new Linux distribution release. Starting simple, this works: ...
0
votes
2answers
48 views

find files in linux with some exceptions

I am trying to make a command which will find all the files modified in past 24 hours and which are PHP only with a loop to look into each public_html directories and save the output into a HTML file ...
0
votes
6answers
39 views

How do I deal with directories that have spaces in their names from `find`? [duplicate]

I have this: #!/bin/bash for file in `find . -type d` do echo $file done If I have just one directory called My Directory, the output is My Directory How do I fix this? The echo $file is ...
2
votes
2answers
63 views

Separate filename and path inside find command's -exec option

I'm struggling with escaping and expression evaluation. I am trying to run a command inside a find...-exec COMMAND structure, where COMMAND operates on one file and outputs to the stdout. To use ...
3
votes
3answers
255 views

Getting the -exec option in find to work

I am trying to make find print out a list of directories that contain files other than jpg images, but I think my use of the -exec option is broken. My environment is Cygwin Bash. $ find ! -iname ...
1
vote
4answers
101 views

Bash rename 360 000 files using find -exec

I've got around 360 000 files like: ./001/1/1.jpg ./001/1/2.jpg ./001/2/1.jpg ./002/1/1.jpg ./003/1/1.jpg ... pattern: [60 dirs]/[1000 subdirs]/[4-10 files].jpg I want to rename files using rename ...
4
votes
1answer
54 views

Find files recursively that are older than one year and not owned by a specific user

I'm trying to find any files on a specific mount that are older than one year and do not belong to a specific user. This is the command I'm using (within the root directory of the mount): find . ! ...
0
votes
1answer
33 views

Tried to mv folder, now having trouble finding folder

Yeah, so I was trying to move a folder around, and now I'm having trouble finding it. Originally it was in my .../Downloads/ directory. I did: sudo mv Downloads/Blah/ ~/ ... which seemed to work ...
2
votes
2answers
82 views

Did I unintentionally delete my entire hard drive?

A while ago I backed up a Linux folder onto a Windows disk drive I had lying around. Recently I was scanning through those files when I realized that I had unintentionally copied over many unwanted ...
1
vote
2answers
39 views

Delete all files by find

How to delete all files found by this command? find -type f -name "*-thumb.png"
2
votes
2answers
64 views

mv command error “already existing file”

I am using a simple script to create some directories. Finding some specific files by name and then moving them into the directories that I have created. The code that I am using is below: mkdir ...
5
votes
3answers
64 views

Find latest copy of same file in folder structure

I need to get the path of foo.txt in a folder structure. There are multiple foo.txt files in this structure but I need an automated to find the latest. Suggestions?
2
votes
4answers
66 views

how to find files based on filename range?

I have some files with numeric names: 2341a.po, 4567211someword.po, 0012.po, etc. I would like to find a set of files based on the numeric range. such as [126 - 363]. Normally I use regular ...
0
votes
1answer
35 views

use basename in find -exec?

If I just use basename {} .txt, it will work: find . -iname "*.txt" -exec basename {} .txt \; It will just print xxx instead of ./xxx.txt if I want use $(basename {} .txt) in the -exec option, it ...
3
votes
4answers
119 views

How to swap entire html blocks in multiple files with sed

I have tons of html pages with a simlar content as follows: <div class="wrapper"> <div class="aaa"> ...lot of html1 here like div's/spans etc.. </div> <!-- end aaa --> ...
0
votes
2answers
33 views

How to recursively delete a dir after find [duplicate]

find . -name "DIR-NAME" -type d -delete because i want to delete specific dir name recursively well it returns find: cannot delete `./DIR-NAME': Directory not empty which is expeted but I have ...
3
votes
2answers
28 views

How to find a file with partially specified path?

I am trying to find all my .txt and .csv files in my backup (Apple's time machine). The structure of the backup directories is like this: /machine name/date/Macintosh HD/ The above contains all ...
0
votes
1answer
37 views

How to change date format and position in find output

Sorry if this a basic question. Say i have the following command. It's set to display a list of the last 20 files modified on my drive with the paths included. find -type f -printf '%TY-%Tm-%Td %TT ...
-3
votes
1answer
53 views

How to tell xargs to unpack tar into certain directory [closed]

I wrote my first script which goes: find /media/temp/test -type f -printf '%T@ %p\n*.tar.gz' | sort -n | tail -1 | cut -f2- -d" " | xargs tar -xvpf I would like to find latest modified file which ...
2
votes
2answers
76 views

How to find a specific file and move it to a specific directory?

How to find a specific file, and move it to the specific directory /var/tmp? For example I want to find the file 0914_Jul-2014.gz. Remark, the file 0914_Jul-2014.gz, is under ~300 subdirectories: ...
3
votes
3answers
160 views

Using `find`, how can I get `rm` to print a fuller path name than it does when executed through `-execdir`?

Summary of Answers: while literature promotes "-execdir" as safer than "-exec", do not ignore the operational difference. The former is not a simple reimplementation of the latter. Also, when using ...
4
votes
2answers
118 views

Find and create empty files with the same name in another location

I want create empty files with the same name, but in another location. Is it possible? find some files use only filenames touch an empty file in another place Something like this: find . -type f ...
0
votes
1answer
65 views

bash: What is the difference between these two script variants?

(Note: Both of these examples may require GNU or BSD find and may not work as-is with the POSIX "edition" of find). Both of the scriptlets below must be understood as excerpts from way more complex ...
1
vote
1answer
29 views

In which directory is node running?

In trying to figure out how some application that listens on port 8088 is running, I see that it has PID 15020: $ netstat -ntulp Proto Recv-Q Send-Q Local Address Foreign Address ...
1
vote
1answer
29 views

Copy only files between two times [closed]

I'm trying to copy pictures taken between two times, from one directory to another. I’ve managed to list them using this command find /mnt -type f -name "*.jpg" -newermt "2014-12-14 01:00:00" ! ...
1
vote
1answer
25 views

How do I find/list all files on filesystem with a certain SELinux “fcontext”

I'm having trouble finding information on what command, presumably from setools, I should use to find all the files on my filesystem that are labeled by SELinux with a certain file-context (fcontext). ...
1
vote
1answer
55 views

Change file ownership recursively without errors

I am trying to write a script that fixes the ownership of all files owned by a specific user, after changing the user's UID. Currently, I run: chown -Rhc --from=${OLD_UID} ${NEW_UID} / chown -Rhc ...
2
votes
1answer
71 views

Find files older than x amount of time in specific directory with ignoring subdirectories

My setup is as following: folder structure dir |--correctfile1 |--correctfile2 |--correctfile3 |--subdir1 |--wrongfile1 |--wrongfile2 |--wrongfile3 |--subdir2 |--subdir3 I need to ...
0
votes
2answers
42 views

How to save stat of all files found in a search?

I had a cron which removes all files with a specific pattern from temp. find /tmp/* -type f -iname magick-* -exec rm {} \; Now, I want to log the stat of all files before deleting them for future ...
4
votes
2answers
247 views

How to quote arguments with xargs

Suppose that I want to delete all files in a folder that are greater than 1 MB. $ find . -size +1M | xargs -0 rm This will not delete files that have space in their names. So I want it to quote all ...
3
votes
1answer
47 views

How to find files/directories with specific ACL

How to I do something like find . -acl u:jim:rx find . -acl u:*:r find . -noacl u:jim:r etc. I know that the find command does not support this but, you have the idea. Are there any scripts, even ...
2
votes
3answers
238 views

find, xargs and mv: renaming files with double-quotes, expansion and bash precedence issue

Ok, I'm simply trying to strip out double-quotes in my filenames. Here's the command I came up with (bash). $ find . -iname "*\"*" -print0 | xargs -0 -I {} mv {} {} | tr -d \" The problem is the ...
2
votes
2answers
71 views

Deleting files older than a month [duplicate]

Need to delete all sub-directories which are a month old. But last day of the month data should be ignored for previous three months. The data representation is as follows: bkp_01102014 ...
0
votes
3answers
48 views

Cannot prompt user using rm bultin prompt option -i with xargs and find

I am using xargs and rm with find in order to remove files that follow a specific pattern defined by find as follows. touch file find . -name file | xargs rm Everything works fine with the above ...
2
votes
1answer
43 views

find command sometimes results in non-matching files being zipped

I'm trying to make a zip file of all the files in a specific directory which were modified in the last x minutes. Here's my command: find "/path/to/dir" -mmin -30 -not -name ".*" -exec zip -r ...