Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [find]

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

1
vote
0answers
13 views

Find + regex: looking for a file name with multiple extensions, but missing the basic filename.jpg

I'm both a regex & SE Unix and Linux newbie, so I hope I'm doing everything right. I'm looking for files that have a name inside of the filename, and could have different extensions. I based my ...
0
votes
2answers
35 views

Print all subdirectories in the current directory that do not contain a .git

I'm trying to write a bash line that will look at all the subdirectories in my current folder and tell me if any do NOT contain a ".git". Pseudo: for subdir in currentdir if .git does not exist ...
0
votes
2answers
40 views

Recursively replace path in a files in directory, except binary files

How to recursively replace strings (location path) in the files in directory, except binary files? I tried command find . -type f -exec sed -i 's/foo/bar/g' {} + but it replaces also strings in ...
2
votes
1answer
31 views

Find command oddity [duplicate]

I've found using the 'find' command to search for individual files that some inconsistencies occur. Eg, I wanted to search for a particular file with the word paper in its name. If I type sudo find /...
11
votes
5answers
2k views

How to sort human readable size

I'm basically looking for files then sorting by the size. The script works if I don't sort the size by human readable. But I want the size to be human readable. How can I sort sizes that are human ...
-1
votes
2answers
48 views

Display contents of the file searched by grep or find command [closed]

I have lots of directories in a certain directory and I am trying to find a specific file present in there. I used grep command recursively and was able to locate the file being present in there, but ...
-2
votes
1answer
40 views

Why can't i “find” files *.png [duplicate]

System: Ubuntu 11.04, regular user account: find /usr/share -name *.wav works okay, but if i do: find /usr/share -name *.png it does not produce any output How do i change the last command to ...
2
votes
1answer
38 views

How does find -name work?

I can't for the life of me figure out how find with the test -name works. I run find / -name *in and returns a bunch of results: /sbin /sbin/sulogin /dev/stdin to name a few. It's as if it ...
1
vote
2answers
26 views

Discard “access denied” stderr natively in find

Is there an option in find that allows me to suppress the error messages that I get from it trying to access directories for which I don't have access? I know I can just discard stderr, but it seems ...
0
votes
0answers
24 views

run script continuously and check for error

I have written below script and it reads the file and when ever there is any 400* or 500* word it will give me error message, and now I want to add two more functionality to my script. I added the ...
0
votes
1answer
51 views

Is Unix find overwhelmed by multiple prunes and type f?

I have spent days on this Rubik's cube. Anything I do to fix one problem breaks another. I am on POSIX compliant MacOS X 10.5 thru 10.14. I am calling this from a Perl script in a context of ...
0
votes
1answer
35 views

Find file name in content of other file [closed]

There are many text file in folder. I want to know which file's contain that mention to other file name in folder example: Is name of file1 has mention in other file in folder1? folder1 ├── folder1....
0
votes
1answer
16 views

Explaining xargs output from two find commands

I have a directory structure of folder1 folder2 folder2a folder2b folder3 folder3a folder3b I am confused by the xargs output of the below command: XXXXXX:folder1 user$ find . -type d -...
0
votes
2answers
48 views

only use the filename for move

I have to move some files from one folder to another, criteria set by a find and grep. When I try to move the files it breaks. The actual move it's trying is mv /somefolder/export//somefolder/storage/...
0
votes
1answer
29 views

Can't seem to concatenate multiple files in different directories

I'm trying to concatenate multiple files together that are in different directories using the following command: ~$ find . -name ‘*.text’ -exec cat {} >> combined.text \; However it doesn't ...
0
votes
1answer
12 views

CronJob command to delete multiple subdirectories by name in a given directory

I have two IP cameras which are sending image snapshots to an FTP server every 10 seconds, from 08:00 to 20:59. The directory structure looks like this: `-- public_html `-- securitycams |-...
0
votes
4answers
56 views

Linux command to find and remove text from several files at once

I have my site infected by a virus. This virus added this line in several files in my site. My idea is to remove this line of text with a unique command from the terminal. Let's say I have the folder ...
1
vote
2answers
30 views

Busybox: Find all files on partition that have been modified since power-on

I am trying to come up with a Busybox-compatible script (or one-liner) that lists every file inside a specified partition that has been modified since the last power-on. This should include files that ...
1
vote
1answer
37 views

How to express `find`'s -writable and -readable tests, when they are not available?

Sometimes on old Linux systems, I experience that find doesn't support -writable and -readable tests, which test whether the file or directory is writable/readable resp. for the current user. Say, I ...
1
vote
2answers
53 views

Why does `find -type d -exec rmdir {} \;` command produce “No such file or directory message”

For testing purposes, I created the following directories. user@linux:~$ mkdir dir0{1..3} user@linux:~$ ls -l total 12K drwxr-xr-x 2 user user 4.0K Mei 31 10:45 dir01 drwxr-xr-x 2 user user 4.0K ...
0
votes
0answers
37 views

BASH Script to find files of multiple types

I switch a lot of people from Windows to Linux. As we all know, not all files on Windows end at their intended location (i.e.: the Downloads folder). I'd like to run a BASH script to search for all ...
0
votes
1answer
37 views

find command - how to ignore case in -path option?

when searching filename or dirname case-insensetively, we can use option -iname. but if I want to ignore case in -path option, what should I do? can I do it with only find command, without using ...
0
votes
0answers
17 views

find -name vs locate [duplicate]

Why this command: locate $FILENAME is NOT the same of find / -name $FILENAME 2>/dev/null ? Sometimes locate finds nothing, while find never fails.
0
votes
3answers
54 views

How do I use command line arguments passed to a shell script that uses xargs?

I have a script that will iterate a set of git checkouts and run a git command in each directory. I now want to be able to pass a parameter to the shell script from the command line and have that ...
1
vote
3answers
26 views

How can I eliminate untracked files from find output?

I want to find within my project directory, but I'm only looking for files that are tracked by Git. Is there a command I can use as a filter for the find output (or any other means) to limit the ...
0
votes
0answers
54 views

What is a great way to list files found in a directory that add up to a certain file size

This list will then be used to create tar balls for easy movement. This is what I came up with so far. Add up files that are just greater than 10GB list them to file. find . -type f -exec ls -al {} ...
0
votes
0answers
33 views

Continuously detect a change of chksum of files under folder with inotify-tools [duplicate]

I just installed inotify-tools. I would like to continuously detect change of chksum of files under folder /path Once a change was detect ( under /path ) then it will print echo “chksum of files ...
0
votes
2answers
49 views

Get filenames and write them on place of previous namespace

I have hundreds of sources codes files. I want to rename namespace according to the filenames path. Of course slashes must be replace by dots. I have tried with find -exec but I failed to get the ...
-1
votes
0answers
43 views

find with -not -name not filtering out the previous -name files

I am working on a script which gunzips files older than X days. I am using below command to skip the existing gzipped files howevere it still not filtering out the existing gzips find /home/xyz -...
3
votes
1answer
33 views

Can the output of find with the -printf flag be colorized?

The command find . -type l -not -xtype l -printf "%p -> %l\n" prints all nonbroken symlinks under the directory .. I want to colorize this output so that the %p part is blue. I've tried find . ...
9
votes
6answers
601 views

Finding all files with a given extension whose base name is the name of the parent directory

I want to recursively look for every *.pdf file in a directory ~/foo whose base name matches the name of the file's parent directory. For instance, suppose that the directory structure ~/foo looks ...
0
votes
2answers
55 views

Unix command to get 0 count , when no files present for the day along with count

How to do I get the list days were no files been received. Have used the below command to get the file count along with the date: find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=...
0
votes
1answer
39 views

How to find duplicate directory paths even if the contents are different?

I've searched high and low but it seems all but one (Find and list duplicate directories) topic I've found actually deals with my situation, and the result isn't quite what I need. Edit: Here's some ...
6
votes
2answers
124 views

find not returning expected files

I'm trying to find some large files in a specific location: This command works and returns some results: admin@tyrell:~$ sudo find /nfshome/*/.local/ -type f -size +1G -exec ls -lh {} \; -rw-r--r-- ...
4
votes
2answers
44 views

list files with specific group and user name

Do you know a command to list all files on the server with specific group and user name? I am looking for something like this: find -ls -group 'groupname' && find -ls -user 'username' this ...
2
votes
2answers
62 views

find -exec and increment counter / progress

TL;DR: Q: How to keep a counter in find -exec loop ? My use-case: I need to move a lot of directories which are scattered around the place, so I do find . -type d -name "prefix_*" \ -exec sh -...
0
votes
4answers
54 views

Find name of directories that don't contains specific subdirectories

I have several directories like so : Rep1/foo/bar/files Rep2/foo/otter/files Rep3/foo/bar/files ... What i'd like to have is the name of the directories that doesn't have the subdirectory */bar/ ...
0
votes
2answers
48 views

Filtering find output to find only the real source files?

I have a big directory tree with sources files (*.c), where some, (but not all), of which are actually generated via a preprocess which produces the whatever.c from a whatever.qc file. Often, I find ...
3
votes
1answer
54 views

Find files then move them and rename them at the same time?

Currently I use three steps to gzip some static assets and then use s3cmd to an S3 bucket (technically it's a Digital Ocean Spaces bucket). Here's what I do: $ find . -type f -name '*.css' | xargs -I{...
0
votes
1answer
61 views

entr: recognition of new files recursively

To keep track of newly added files in a directory (and it's subdirs) I want to use entr ls -d /tmp/* | entr -p notify-send "new file added." But when I add new files to /tmp/ or /tmp/foo/ nothing ...
2
votes
1answer
64 views

Wrong results while using “find” in terminal

What am I doing wrong and why I need to use "/" to get correct results? And if I need "/" what is the purpose of it and how do I input it using terminal? Going thru "media" was just an accident and I ...
1
vote
1answer
31 views

Attempting to only copy files that have changed within the last day while maintaining folder structure

I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data ...
0
votes
1answer
33 views

How to correctly escape command arguments from an environment variable

I'm trying to merge the output of 2 find commands and pipe it to the next operator. The arguments passed to both find executions are very similar so I'd like to keep it DRY FIND_CMD_ARGS="-type f \( -...
2
votes
2answers
90 views

How do I delete files except some specific files passed as parameters?

The task is to write a shell script with n+1 arguments where the first one is the directory and the rest is the specified files and will delete all but specified files. E.g. calling rmexcept . '*....
1
vote
0answers
24 views

Which tools can find unicode (UTF-8) text in files containing any form of normalization?

I like to find international text, like "müller", or even chinese text, in files, no matter which unicode representation and case is used. I.e, it should not matter whether the "ü" is stored in NFC ...
0
votes
2answers
74 views

find exec does not work with command aliases?

macOS Trying to do a find with a -exec of a command aliased in my .bash_profile , find shows find: [alias cmd]: No such file or directory e.g. find ./ -iname *.doc -exec sha256 {} \; where alias ...
3
votes
1answer
127 views

'regex' and 'name' directives in find

What sort of regex syntax does -name option of find command expect? I was of the impression that it would be the same as for -regex but that doesn't seem to be the case. $ mkdir test && cd ...
1
vote
1answer
40 views

Zipping all sub directories

Trying to zip a backup directories inside a parent directory data/ which looks like this data |- 2019-04-01 |- data.gz |- data2.gz |- 2019-04-09 |- data.gz |- data2.gz I would like ...
0
votes
2answers
95 views

How can i terminate 'find' after the first match?

I am using find in a while loop. it takes a list of ips in ip.txt, searches for the ip in a directory of files and then writes the name of the file that each IP was found in to a file called results....
0
votes
2answers
37 views

finding files of a particular pattern

I want to find names of the file having abc in its name. For example: Dozain123.ctabcln_WbLogReq.log' Dozain123.ctabcln_WbLogReq123.log Dozain123.ctabcln_WbLogReq456.log Dozain123....