Questions tagged [find]

For questions pertaining to find, a command-line utility to search for files in a directory hierarchy. Use this tag for questions about find itself or questions about issues arising from using the find command-line utility.

Filter by
Sorted by
Tagged with
2
votes
3answers
34 views

How to check and assign execute permission to the shell script files?

I'm looking to write a .sh script to assign execute permission to all .sh files that have not been assigned execute permission in the current directory and subdirectories. I can easily assign execute ...
0
votes
1answer
30 views

Creating an alias for the find command in Linux

I have created the following alias in my .bashrc file: alias find='find . -type f -name' This obviates the need to type . -type f -name every time I do a file search. However, I still have to enclose ...
1
vote
2answers
54 views

combine `find -printf` and `find -exec grep -l`

How can I find files that contain specific content (grepable) and sort the found files by last modified time? (I want to select just the one newest file) This command finds files: find subfolder/ -...
0
votes
2answers
55 views

Removing last element from bash array

I am calling find by constructing an array isufx containing filename suffixes. Thusly, I have echo "isufx: ${isufx[*]}" that results in -name *.texi -o -name *.org -o Finally I got the ...
2
votes
4answers
653 views

When are grouped parentheses for multiple options necessary?

I am using the find and grep commands. Getting quite confused about when multiple options are joined by "or" with the -o flag and the use of grouped parentheses, and when grouped parentheses ...
1
vote
0answers
32 views

missing argument to `-exec' with `find` in Cygwin

I'm new to Linux and trying to work with rsync. I want to sync only file/folders that are created or modified in last 1 days or less. I'm using cygwin to sync windows files into Linux. I tried below ...
-1
votes
2answers
53 views

Find log filenames that MUST end with any char but not only “.log”

I need to find all log files older than 5 days and that the filename MUST ends with .log AND any character (i.e. first.log20210701 but not first.log). I tried this command but it shows also "....
0
votes
2answers
54 views

Find directories and merge files

So I have a file system of thousands of subdirectories in the form 304880.US 906T89.DE 032848.UK 023455.UKREGRESS : Sometimes inside the folders there are other folders called 1, 2 and 3. Each end-...
3
votes
1answer
53 views

Does + need to be escaped in find commands?

I have the following code in bash and I wonder on whether I can get rid of \+ and simply use + find "$fdir" \ -type f -name "*.org" -o -name ...
0
votes
0answers
26 views

Beginner linux find -exec command how to use it and find help or manual or tutorial? [closed]

it seems obvious for many but to search on files or directies I found, command such as: find ./ -iname '*.wma' -exec bash -c 'echo "{}"' \; If I can find a manual or help on the find ...
0
votes
2answers
45 views

Map over file tree, preserving structure

I have a file tree that looks like: $ tree src src ├── bible │   ├── index.md │   └── README.md ├── index.md └── other.md I want to render every Markdown file within this file tree to HTML via pandoc(...
4
votes
0answers
43 views

Why usual commands can't see a file within a cifs mounted directory?

I have a case where an existing file within a CIFS mount hosted DELL/EMC Unity appliance can't be seen by ls, find or tree. Only giving the absolute path of the unseen file makes ls and other commands ...
0
votes
0answers
21 views

find files with peculiar permissions set [duplicate]

I'm prepping for the LPIC1 exam, strongly relying on their online material here. Can someone pls help me clarify this doubt? What is the difference among these: find ~ -perm 4000 find ~ -perm -4000 ...
1
vote
1answer
46 views

find files satisfying both requirements simultaneously

I have never before needed to use find with multiple search terms. I found this: find . -type f \( -name "*foo*" -o -name "*bar*" \) ..but it finds files which satisfy either of ...
0
votes
2answers
46 views

How to find content in Curly braces

I have a file: [{ abc def 123 }] [{ abc 456 789 }] var="789" i want find (grep sed ...) $var return results Curly braces : { abc ...
1
vote
2answers
59 views

Capturing parameters sed

I am trying to replace occurences in bunch of html files. I want to update the files with the new subdomain name. old urls look like this : https://123.olddomain.com/wp-content/ New ones should look ...
1
vote
1answer
34 views

Passing file types to bash function and calling find

I have the following bash function to print between two line numbers, for files watching file types .texi and .org recursively in a particular directory. I would like to be able to supply the file ...
13
votes
3answers
2k views

List all files with extensions .tif, .tiff, .TIF, .TIFF

Given a nested directory, I would like to list all tif files with extension .tif, .TIF, .tiff, .TIFF. Currently I'm using find . -type f -iname *.TIF -print ; find . -type f -iname *.TIFF -print; ...
0
votes
0answers
25 views

Bind mount with mindepth option?

Is there a way to use something similar to the "mindepth" option of the find command with a bind mount ? Here is my directories and files structure : level 0 directory ├── level 1 directory ...
0
votes
1answer
42 views

I want to find all the greater than 100 MB and older than 20 day and want to zip them only .TXT and .txt files individually

I'm using find $HOME -type f -size +100M -mtime +20 -exec zip -m '{}.zip' '{}' \; This command is compressing all the files. I want to zip only *.TXT and *.txt files only. Any idea how can we do ...
0
votes
1answer
30 views

Help with script to zip and purge existing file

I am using the commands below to compress and truncate files. I need help to combine this into one command. find *scan*.log -type f -size +1G |xargs -L1 -I file zip file.zip file find *scan*.log -...
0
votes
1answer
53 views

Why locate gives more lines output than find

For example I will look for everything which contains 'bin' in its name locate 'bin' gives me 7732 lines of output sudo find / -name '*bin*' gives me 2730 lines of output why?
0
votes
1answer
28 views

How to tell 'find' command to jump to a position and search? [duplicate]

I'm preparing headers for a C++ project and I decided to use find to get include option to other header files. To list the right path, I need to use cd with it, like: cd 'PATH/TO/HEADER/FILE' find ../....
9
votes
3answers
440 views

How to search for multiline text files containing a set of words (e.g., AAA & (BBB | CCC) & ~DD)?

I need to find the files that fulfill relatively complex condition. For example, I want to find all files that fulfill all below conditions: does contain word AAAA does contain word BBB or CCCCC (may ...
-1
votes
1answer
88 views

Output of this command Linux [closed]

Please do anyone has an idea about the output of this command , I have googled a lot about it but I can't find anything useful find . -type f -exec grep -H PATH {} \; Thanks in advance
2
votes
3answers
131 views

Renaming directories with find and mv on macOS

I am struggling with a command to rename directory and files. OS: MACOS 11.4 Objective : rename directories and file by replacing the space with a underscore _ Command tried : find . -maxdepth 1 -...
0
votes
2answers
33 views

Find files with Julian days in a specific range in their names

I have a list of files that contain a Julian calendar date in them. Examples: XXX_YY_AB21123.TXT, XXX_YY_AB21124.TXT etc. I have hundreds of them for the year. I need a way to search for the files ...
1
vote
2answers
16 views

batch comparing files sharing a prefix with htmldiff

I have a bunch of files named like this: something08-a-v1.html something08-b-v2.html something09-a-v1.html something09-b-v2.html somethingelse10-a-v1.html somethingelse10-b-v2.html -a- is a previous ...
6
votes
1answer
393 views

'find -empty -delete' deletes non-empty directories

If I create the following directory structure: mkdir -p dir1/dir2/dir3/dir4 then I run find dir1, it returns: dir1 dir1/dir2 dir1/dir2/dir3 dir1/dir2/dir3/dir4 If I run find dir1 -empty, it returns ...
2
votes
1answer
72 views

Find file glob pattern or regex by name but allow for exact match at beginning and only certain characters at end

I am trying to match some image files which share a basic name but have sizing information appended to the end with find . -name 'Name*' to match files such as: Name.jpg Name@2x.jpg Name-180x101.jpg ...
-1
votes
1answer
42 views

How to move old logs - mysql logs [closed]

I need to move old binlogs to a directory and aso compress it before moving it to a new folder. I have a space crunch because of which we am facing issues. below commadn is not working. ls -t binlog* |...
0
votes
1answer
38 views

How do I find duplicate lines in multiple files within folders

when i want to find duplicate lines between two files i use this command comm -12 <(sort file1.txt) <(sort file2.txt) or sort file1.txt file2.txt | awk 'dup[$0]++ == 1' But, how do I find ...
5
votes
2answers
156 views

No space left on device when moving 700k files to a single directory within the same FS

I use the following command to find and move a huge number of files on my server: find SomeDir/ -maxdepth 10 -type f -mtime +90 -exec mv {} SomeDir2/ \; After moving about 700,000 files, I get this ...
0
votes
0answers
21 views

how to find the lines by ignoring word sequence, in Linux? [duplicate]

I am trying to ignore the order of the words and searching for the line in one file which has below pattern for example : My Name is ABC. Now I want to change the sequence of words in the same ...
0
votes
2answers
38 views

How to find all directories with more than x number of files that are larger than a specified size?

How to find all folders in a directory with more than a specified number of files that are larger than a specified size? One exemplary use-case is finding folders with split movie files which could be ...
0
votes
1answer
22 views

find -newerct filter on cp-copied files has different result compared to original files

I've migrated some 73k files from source/ to dest/ with cp -pR. Before I did that I checked with find source/ -type f -newerct $(date -d @1623247288 +"%Y-%m-%d") that I can grab new files. I ...
4
votes
3answers
99 views

Find all directories that contain only hidden files and/or hidden directories

Issue I have been struggling to craft a Bash command that is able to recursively search a directory and then return the paths of every sub-directory (up to a certain max-depth) that contains ...
2
votes
2answers
47 views

Find a resource that is missing OSX

On OSX (big sur -so Zhell)I have a folder that contains .bundle files , each bundle containa several files and folders. in most of the files there is a resource called PNG_.zip and some do not. ...
3
votes
2answers
104 views

Parent child directory same name , move files to parent directory

I need a way to search directories for child directories with the same name and then move all files in the child directory to the parent. Thus from /recup-dir1/recup-dir1/files to /recup-dir1/files. ...
2
votes
1answer
24 views

How can I move files to different directories depending on their contents?

I have many files which contain a string like this: /databis/defontis/Dossier_fasta_chrm_avec_piler/SRR6237661_chrm.fasta: N putative CRISPR arrays found Where the N is a number that can be either 0 ...
1
vote
2answers
56 views

Search and replace with find and xargs not working

I am trying to search and replace a url present in source code of html/css files in target folder and subfolders. I have tried to use the following command : find . -type f | xargs sed -i 's/https\:*\...
12
votes
5answers
1k views

How to mark directories in the output of the `find` command?

For example, I looking for files and directories in some directory: ubuntu@example:/etc/letsencrypt$ sudo find . -name example.com* ./archive/example.com ./renewal/example.com.conf ./live/example.com ...
1
vote
1answer
36 views

How to extract folders, split filenames in key and value(s) and save it in an associative array?

I have following script which is supposed to solve the problem from the title, but obviously it isn't working to assign the values to the keys. Is the reason an accidental error or is there a ...
0
votes
1answer
28 views

Find working with regexp in same CWD but not from another directory

I have a find command and I would like to issue it from an arbitrary directory with a $directory variable in place of the dot . for the current working directory. What works is this Example 1 find $...
1
vote
0answers
38 views

Select one out of 2 specific files, copy and rename it

I need help running code locally using a terminal app called NewTerm2 on my iPhone (this app has limited functionality but it's more comfortable with unix commands) Here's the case: I have this tree /...
0
votes
1answer
38 views

Need help with xargs and substitution

I got some command below, and I need to use the parameters passed inside of my xargs command to my echo command but I cant seem to get it right? If I try: find . -maxdepth 1 -type f -wholename "$...
2
votes
2answers
45 views

How to remove four random characters before the .extension from various files using a for loop?

I am working on an undergraduate research project that is heavy in bioinformatics, and I am going down a pipeline of file processing. Some background: I am working with shotgun metagenomic data which ...
1
vote
1answer
28 views

Anchored excludes with find or fd

Let's say I want to find all files in a directory (recursively), but omit those e.g. in .git and node_modules subdirectories. I can do: $ fd -uut f -E .git -E node_modules But that will, for example, ...
5
votes
3answers
495 views

How to recursively set directory permissions with a find that lacks -exec?

My Qnap NAS is cursed with a find command that lacks the -exec parameter, so I have to pipe to something. The shell is: GNU bash, version 3.2.57(2)-release-(arm-unknown-linux-gnueabihf) I'm trying to ...
1
vote
0answers
41 views

I have a text file with a list of files I need copied how do I do this?

I have a text file that has a list of files with each file name on a new line. Those files exist in multiple subfolders. I need to copy those files to a separate folder where all of the files that I'm ...

1
2 3 4 5
62