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

learn more… | top users | synonyms

1
vote
0answers
70 views

Help with MKV to MP4 Remux script [closed]

Overview: I'm trying to remux my mostly MKV library to MP4. I have a script that has gone through and extracted subtitles from the video files. I have another script that will remux any .mkv files ...
4
votes
3answers
181 views

Remove long string from files

Files on my server have been corrupted. I want to remove a 13000 character string from all PHP files containing it. The string looks like: ?php if(!isset($GLOBALS["\x61\156\x75\156\x61"])) { ...
3
votes
3answers
125 views

Using basename to strip file extension and search for files with the same name

Basically, I have a folder /test/ that has a number of files of type .doc and .pdf. Some of the files have a .pdf and a .doc version, such as test.doc and test.pdf while others only have one version. ...
0
votes
1answer
122 views

How to use find command to execute two conditions in linux

I am trying to delete files (log files) which are more that 5 days old and I need to keep one specific file without deleting, I tried it using find . -type f -mtime +5 ! -name 'test2' -exec rm -f {} ...
0
votes
1answer
2k views

find: cannot fork: Cannot allocate memory

I want to delete 1 file at a time from my directory which contains so many files,So i want to remove 1 file at a time. Just to avoid too many reads and failed at too many arguments. find ...
0
votes
2answers
41 views

Find the position of repeated character “&”

How can determine the position of “&” in the column number 5 to substring the value 2 or substring value 3 by awk functions column1|column2|column3|column4|variable1:value1 & ...
0
votes
0answers
19 views

How to exclude path in “find” [duplicate]

How to exclude Time Machine backup folder (/Volumes/Backup/Backups.backupdb) in find? I have now this but it also goes through TM folder: do shell script "find -x " & fr_where & " -print0 | ...
1
vote
1answer
34 views

Pruning not working In find

find . \( -type f \) -o \( -name "*.rpm" -prune \) find . \( -name "*.sh" \) -o \( -name "*.rpm" -prune \) The second command excludes .rpm but the first one doesn't. What's the problem with ...
0
votes
1answer
47 views

What is the barebones simplest way to recursively rename one extension to another? [duplicate]

I've done a fair share of googling and I've found some rather complex solutions. I feel as though there must be something simpler. Let's say I have ./1.txt ./2.txt ./more/3.txt ./more/4.txt ...
0
votes
0answers
125 views

rsync, find, and other useful commands for synchronizing a large quantity of data

Here is the structure of the folders I would like to consider: /mnt/network/ is my network drive and /local/ is my local folder. What I want is to synchronize the content of these two folders ...
2
votes
4answers
342 views

Human-readable filesize with find's printf

I am writing a simple helper function to show a specific folder in the format I want: find . -maxdepth 1 -not -name "." -printf '[%TY-%Tm-%Td]\t%s\t%f\n' | sort -n However I want to show the ...
2
votes
2answers
84 views

Combination of find command and sed (stream editor)

I am trying to find all directories in /proc with names containing only numbers and belonging to users other than "root" I have already tried this: sudo find /proc -type d -user | sed -n '/[0-9]/p' ...
0
votes
1answer
54 views

find by name or by grep

find . -perm -u+x,g+x,o+x -type f -exec grep -i -l -H -E '#!/bin/bash|#!/bin/sh' {} \; 2>/dev/null 1>/$user_scripts I am tasked with finding any script that could exist for N users in 4 ...
1
vote
3answers
151 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 ...
3
votes
2answers
104 views

Using find -exec how to print name of file in front of each line?

Similar to, but beyond: find . -iname "somepatter*txt" -print -exec cat {} \; How might the file name from each file be printed in front of each line with the results from find?
1
vote
0answers
39 views

What are the major differences between the Darwin/BSD and GNU versions of Findutils?

OS X comes with its own versions of find, locate, and xargs. GNU versions of these utilities are also available as part of GNU Findutils. What are the major differences between the two versions? Is ...
1
vote
1answer
92 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 ...
0
votes
1answer
264 views

Copy all files matching criteria on find command with -exec

Below are my attempts at copying all files except .out and .class files into a subdirectory titled homework21/. Note homework21 is a subdirectory of the folder in which I am working in. ...
2
votes
1answer
162 views

How to get list of files with not having search string [duplicate]

I have a requirement to display all files in a directory which doesn't have CountOfFilesTransmitted=0 string in them. If I give below command it gives only those files which has ...
3
votes
2answers
133 views

Why does deleting directories generate error messages with find -exec?

Why is it that: find . -type d -name test -exec rm -r {} \; generates error messages: find: ./foo/test: No such file or directory find: ./bar/test: No such file or directory find: ./blech/test: No ...
4
votes
2answers
66 views

How to use the results of “file” (Name of Creating Application: Microsoft Word) to search for a specific string?

I am trying use the results of "file" which returns info about the file/s I specify. E.g. file *.doc 'all .doc extensions This then returns information about the file including "Name of Creating ...
0
votes
2answers
62 views

sed search and replace problem

I am trying to replace a string from a file which contains '&' in its value. vari = '111|abc & efg|123' varj = '222|abc & efg|123' echo $vari | sed -e "s/$vari/$varj/g" output is ...
1
vote
1answer
49 views

Can I use Zsh's built-in wildcard matching to replace the use of `find` here?

This is a follow-up to another question I posted I use a script to automatically rename files according to a particular order: #!/usr/bin/env zsh pages=($(sed -n '/page_order/,/^$/ p' _config.yml | ...
6
votes
1answer
50 views

GNU find -[cma]time option and daylight saving time

In the GNU find man, you can read this about the -atime option: -atime n File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last ...
2
votes
2answers
89 views

Identify sub-directories that do not contain a specific string in a specific file

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I need to find sub-directories that either do not contain a file stdout or if they do, that ...
0
votes
1answer
92 views

find command doesn't find (readable) files as non-root user

I'm trying to figure out why find does not find my files, even when they are readable. I have the following directory /some set up drwxr-xr-x 2 root root 4096 Sep 23 16:45 some It's readable by ...
2
votes
1answer
69 views

Check for related file names and delete one of them

I need to write a script that will find files that contain a string in their name. If a file exists that is the same name but without that string, I want to remove the original file. For example, if ...
-2
votes
1answer
63 views

Find part of filename

Please help with my task: I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names. I need to create a shell script ...
1
vote
2answers
53 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 -- {} ...
0
votes
1answer
230 views

Find command to check only for the last 10 minutes and not the whole folder

I have an nvr system that recording video surveillance into a file server (Debian). I made a Nagios plugin to check if the NVR system is recording correctly and send me a notification when it stops ...
1
vote
1answer
21 views

copying sub-directories not containing a specific file into another directory

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I get the list of sub-directories that does not contain a file stdout based on solution given ...
0
votes
1answer
30 views

Find filename using list inside a file

How can i find all filenames that match a string in a list inside a file? I have a list_file.txt with a list of email addresses each in a new line like this: 1@mail.com 2@mail.com 3@mail.com ... ...
0
votes
0answers
76 views

Directory research example

I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names. I need to create a shell script that checks all the folders ...
-2
votes
1answer
201 views

What is the difference when using FIND between -name and -iname

Well the question says it all, I have seen both find -name and find -iname used all over the place without a discernible pattern. Could somebody explain the differences, perhaps with an ...
2
votes
2answers
42 views

Pipe Find Results for '*.squashfs' to unsquashfs

I am looking for something that will find the squashed filesystem, and the pass the output to unsquash the fs and it would have to be an absolute path outside the squashfs. example ...
2
votes
2answers
51 views

Copy file and file structure and merge in new directory

I used the following command line find src -name '*.json' | cpio -pdm lib So it found the json file as in the sceenshot below But then it takes the whole directory structure and places it into ...
0
votes
1answer
46 views

Folder research task

I have a folder with 3 subfolders containing 6 files each.There are 2 files in each subfolders with :NOPM in their file names. I need to create a shell script that checks all the folders and their ...
1
vote
2answers
118 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 ...
13
votes
9answers
16k views

How to chain the commands 'date -d @xxxxxx' and 'find ./'?

I have directories whose names are timestamps, given in milliseconds since 1970-01-01: 1439715011728 1439793321429 1439879712214 . . And I need an output like: 1442039711 Sat Sep 12 08:35:11 ...
0
votes
2answers
132 views

How to find all files matching (or not matching) a specific pattern in a folder?

How do I find all files in a folder and its subfolders terminated with 3 digits and move them to a new place while keeping the directory structure? Alternatively, how can I find all files whose ...
2
votes
3answers
62 views

find and md5sum not yielding any output (find -o limit?)

I ran into a situation that I don't really understand. I have a bunch of backup files in a recursive structure of which I want to calculate the md5. When I add some additional file extensions the ...
0
votes
1answer
14 views

Obtain filepath of directories containing a particular filetype in alphabetical/numerical order [duplicate]

I have a directory that contains 800 subdirectories named disp-001 ... disp-800. All these sub-directories need to contain a specific file say stdout. One among them does not contain the file and I ...
1
vote
2answers
193 views

Why is find not accepting '-exec cp {} dir +'?

I have a directory, dir1 which contains many files whose names end in either .jpg or .png. I want to copy all the .png files to dir2 which is empty. This command works: find dir1 -name '*.png' -exec ...
0
votes
2answers
48 views

Bash script to copy specific directories with pattern matching

How can I copy directories from one location to another location that matches a pattern. For example: source = /media/src/ destination = /media/dest/ The pattern is as /b/w{2}_/w{2}/b. i.e all ...
0
votes
2answers
645 views

simple command “find” not working

so I'm in the main folder for my web hosts, trying to find a file using find. I couldn't find it - it was listed as no such file or directory - and I thought maybe it isn't anywhere. However the ...
1
vote
2answers
2k views

How to rename multiple files using find

I want to rename multiple files (file1 ... filen to file1_renamed ... filen_renamed) using command find command: find . -type f -name 'file*' -exec mv filename='{}' $(basename $filename)_renamed ';' ...
0
votes
2answers
135 views

Why does this command not remove files as expected?

This command in my .sh script is supposed to look in /home/backup/VBtest for .sql.gz files and remove any older than 5 days: find /home/backup/VBtest/*.sql.gz -mtime +5 -exec rm {} \; But it ...
7
votes
3answers
1k views

Can someone explain what this command does?

Can someone explain to me what this command does? EDIT: Do not run this command! It will break your installation. sudo find / -exec rm {} \;
3
votes
3answers
339 views

With find -exec grep, how to print only basename or split filename/line content on separate lines?

I'm looking at source files. For PureBasic actually, but whatever the language, there are common elements involved. In my case, the command would be cover extensions pb, pbi, pbf, and pbp: find . ...
0
votes
3answers
41 views

Backing up files [duplicate]

I would like to backup all files older than 90 days and greater plus gzip them. I could execute: find /path/to/files -type f -mtime 90 -exec gzip "{}" \; Problem with this command is it includes ...