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
0
votes
1answer
18 views

No such file or directory Error while using find or ls -al in unix directory

I am trying to find reason behind this happening and also a solution . When I try to run below command on Unix directory which has around 16 files and also one of the application process which keeps ...
0
votes
1answer
48 views

find command generates empty files in linux

I am trying to retrieve the filesize associated with the Logfilename listed in ip_DBfiles.txt with the logfilenames from the server.When matched the size of the file and the filename should be written ...
1
vote
2answers
25 views

Cleanup script with find - No such file or directory

I am using the following to find and delete a group of sub volumes: find /.snapshots/ -name backup-* -type d -exec btrfs subvolume delete {} \; It works, but I get unexpected output from find: Delete ...
0
votes
1answer
42 views

why isn't my 'find -exec du' working?

I want to get the disk usage of a directory tree, excluding branches that begin with '.', and I will eventually want to run this over ssh, so I prefer to not use a pipe. When I run the following, I ...
-2
votes
2answers
58 views

sort and delete older file

How can I sort the below files based on the date and time inside the folder and delete the older ones and keep the most recent ones in Linux? I just want to keep the latest one regardless of the ...
6
votes
3answers
348 views

Finding duplicate files with same filename AND exact same size

I have a huge songs folder with a messy structure and files duplicated in multiple folders. I need a recommendation for a tool or a script that can find and remove duplicates with simple two matches: ...
0
votes
0answers
9 views

How to find files of a given mime type? [duplicate]

find has various options for finding files of a certain extension type. However, what if I want to find files of a certain MIME type? For example, I want to find all files on my computer that are ...
4
votes
1answer
100 views

How to increment COUNTER in -exec script?

Context: zsh Catalina MacOS: The executable script BatesStamp engages imagemagick to stamp a number to a jpg file: # BatesStamp: OVERWRITES and stamps ONE file with COUNTER (upper left corner) # ...
3
votes
3answers
223 views

How to use find with paths that are listed in a file while ensuring that spaces are taken care of?

I have a list of paths that are in a file called pathlist.txt. It looks like so: /home/abc/dirA /home/abc/dirB /home/abc/dir with space /home/abc/dirX I need to find all files in each of those paths. ...
-1
votes
1answer
39 views

Allowing arbitrary files to be matched by find

I am passing arguments to bash function, composed of directories and files. The following code validates the arguments before staring then in the array fdir. declare -A tag for arg in "$@"; ...
1
vote
1answer
35 views

how to total clean the folders from /var/spool/abrt/

we want to delete all abrt folders from /var/spool/abrt/ before we just run the following , to see how many folders we have find /var/spool/abrt/ -type d /var/spool/abrt/ /var/spool/abrt/ccpp-2019-...
0
votes
1answer
17 views

How to search over symbolink links for the existence of a file?

As a follow up on this question, I am trying to determine which command/sequence of commands can give me which of the network interfaces listed under /sys/class/net is the wireless one - by searching ...
2
votes
2answers
98 views

Find pattern: sort and delete older files

I want to delete old files and keep only the most recent from each file pattern based on the first five characters (aa_te, bb_co, cc_co, dd_xy) and the date and time in the file name. Note: All files ...
0
votes
1answer
50 views

Find files with same name but different extension

I have a legacy application (unsupported) that generates PDF files of XLS, XLSX, DOC and DOCX on demand. The disk of that app is full and we need to delete those PDFs. So I'm searching for a script ...
3
votes
2answers
135 views

Deleting all files older than 2 days under specific directory names recursively

I have written this script: #!/bin/bash DAYSOLD="2" users_dir="/users" cd $users_dir date >> cleanup.log; du -h --max-depth=1 | sort -hr >> cleanup.log find $users_dir ...
0
votes
0answers
12 views

stacking multiple `find -execute` invocations [duplicate]

i love find -execute but sometimes i would like to do more complex operations like running find -execute in all matching folders. (e.g. run a script on all header files in a subdirectory tree for all ...
0
votes
1answer
33 views

find all file extension recursively from directory and copy all extension files to single directory [duplicate]

I have directory with sub-dir where it has multiple extensions file. I would like to copy all ext files to single directory "scan". Tried running following cmd but doesnt work out: find . -...
0
votes
2answers
54 views

Move files in bash script to subdirectory extracted from file name

I have a directory with a bunch of backup files like this: projectA20210901.gz projectA20210902.gz projectB20210901.gz projectB20210902.gz I would like to move all projectA* files to ./projectA/ and ...
16
votes
1answer
2k views

Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't

So I'm trying to split a 64MB file FileCarve.001 into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I cat all the ...
2
votes
2answers
81 views

What is an effective way to automatically append file extensions to extensionless files?

I wrote a bash script today during my lunch break that finds extensionless files in a directory and appends a file extension to those files. The script is relatively long because I added a bunch of ...
1
vote
1answer
66 views

Kinda complicated tar based on modified date

Okay, I think this is possible, but I can't quite figure it out. This is the situation. A folder contains the log files of all the processes on my robot. The structure looks sort of like this: $ ls -...
0
votes
1answer
134 views

How to run this simple command in the background

I am having a really hard time trying to run the command below on the background: find /dir -iregex ".*\.\(jpg\|jpeg\)" -exec jpegoptim --strip-all {} \; -exec sleep 1 \; I tried adding ...
3
votes
4answers
779 views

Find with `-exec` but with a delay

I have this code to optimize image size of all my images inside /dir directory: find /dir/ -iregex ".*\.\(jpg\|jpeg\)" -exec jpegoptim --strip-all {} \; When I run this code, it consumes a ...
0
votes
0answers
21 views

Confusion Regarding Slowness Of Recursive Find

This command takes greater than 2 minutes to return: find . -type d -wholename ./dev-abcd/efgh It makes me think there's many subdirectories. I checked that with the below command, which returned ...
9
votes
2answers
402 views

Excluding directories in find

find is always a complete mystery to me whenever I use it; I just want to exclude everything under /mnt (I am in bash on Ubuntu 20.04 on WSL so don't want it to search in the Windows space) from my ...
0
votes
2answers
34 views

check width of image before convert it

I use the following script to convert all jpg and png images: # absolute path to image folder FOLDER="/home/*/public_html/" # max width WIDTH=1280 # max height HEIGHT=720 #resize png or ...
2
votes
1answer
48 views

Copy all PDFs within a listing of directories

I am trying to copy all PDFs within a listing of directories to my temp directory. I have this command to get a listing applicable directories: dirname $(grep -r <my search criteria> /c01/app/*...
0
votes
4answers
70 views

Linux find <DOCKER_MOUNTED_DIR> -type d: how to list the deepest dirs, such as ./dir1/dir2 without ./dir1?

find . -type d normally will show ./dir1 ./dir1/dir2 ./dir3 ./dir3/dir4 ./dir3/dir4/dir5 ... I just want the ./dir1/dir2 ./dir3/dir4/dir5 , without its parent ./dir1, ... In other words, I only ...
0
votes
1answer
26 views

Find occurrences in a list of files and count them

I have a large set of thread dumps which are in a directory tree (one folder for each 30 minutes). I'm trying to count how many Threads are in a single file. So far I've come up with: find . -name '...
1
vote
1answer
90 views

Simple find command will not run

I am fairly new to linux and I am currently trying to run the following command, find ~ -name apt.no I'm looking for apt.no within another directory listed as montrose-files. There is no response ...
2
votes
3answers
511 views

Find: Use regex to get all files with specific directory name in path, but without another specific directory name in path

I'm trying to use find to return all file names that have a specific directory in their path, but don't have another specific directory anywhere in the file path. Something like: myRegex= <regex>...
1
vote
2answers
62 views

How do I store find results in a variable so I can display them before modifying them?

I have this script which finds files with incorrect permissions. If any are found, it asks the user if they want to fix them or show them. The find results are stored in a variable in order to avoid ...
0
votes
0answers
30 views

"Operation not permitted"&"No such file or directory" when using find command

My machine is Macbook Pro mid-2014 Big Sur. Here is my use case: I want to find a book called "How to think like a Java scientist" or something like that. I could use the the built-in ...
-4
votes
1answer
69 views

find command with \; \+ and + [duplicate]

I have seen find commands as follows, and wonder on the difference between them. find . -exec COMMAND {} \; find . -exec COMMAND {} \+ find . -exec COMMAND {} +
0
votes
2answers
25 views

How to calculate disk usage filtering by pattern (e.g., *.JPG)?

How can I calculate disk space consumed only by some files of a directory recursively?
0
votes
2answers
27 views

Tackling working directory for find command

I am passing a pdf file to a script and extracting various parts (e.g. path, name, extension) so that I can find some associated commentaries stored in org files. Would like to tackle files in the ...
2
votes
3answers
145 views

find and sed to replace special characters

I'm looking for an easy way to rename many files on my Synology NAS. find and sed are available, but not rename. I can get a list of these files and folders with find . \( -type d -name "@*" ...
1
vote
1answer
18 views

Finding specific PNG images and renaming them

I have to find multiple files named logo.png in different subdirectories, and change their names to oldlogo.png, how do I do that? I already have the beginning, finding the file (each logo.png file is ...
0
votes
0answers
19 views

Is there an online tool to interactively construct `find` command parameters?

There is but I've lost my browser history / bookmarks. I'm looking for a webpage where you can interactively parametrize find command arguments (like file size / date / search depth / etc.). IIRC, ...
0
votes
0answers
8 views

Search multiple directories with KFind or exclude specific path

Is it possible to search multiple directories with KFind or to exclude a specific path? Via CLI it is easy to do so with find e.g. find DIR1 DIR2 DIR3 -iname "*.txt" and find DIR -path ...
1
vote
2answers
79 views

How to find files that only contain alphanumeric characters?

How to find files that only contain alphanumeric characters and [áéíóúñ.,¿?¡!()]? I have some sparse plain text files and I need to separate them from scripts and any other thing, they're just ...
0
votes
2answers
65 views

Using find + grep + awk in combination

I'd need to filter through a list files (output of top command) for some info: Firstly I need to list files with a find Then, I need to grep for lines with a pattern Finally, I need to pickup one ...
1
vote
1answer
277 views

Why is find returning . but not ..?

Let's assume that I move to an empty directory at the following path: /home/user/dir If I execute: find . ! -name "*.txt" the result is: . But if I execute find /home/user/dir ! -name "...
0
votes
2answers
42 views

List files that match but with any extension

Given a file with path /foo/bar/a.b.c.d.x I would like to be able to find all files matching /foo/bar/a.b.c.d.* with any final extension This is what I have been using thus far findSiblingFiles () { ...
-1
votes
2answers
31 views

Search and replacing a string on specific file extensions with the folder name

I want to find a string ("AAA") in an specific file extension ("*.txt") inside a directory tree (../MyParentFolder), and replace it with the subfolder name (MySubfolder). I know a ...
0
votes
0answers
16 views

Combining recursive find, numbered backup, & copy for multiple files with the same name in subdirectories and subdirectories of those subdirectories

r.xml are the files, and s is output directory. What I want is the s directory to contain r1.xml, r2.xml, etc.. $ ls -R s temp temp3 ./s: ./temp: r.xml temp2 ./temp/temp2: r.xml ./temp3: r....
0
votes
1answer
21 views

Meaning of the '*' at the end of find tool

Recently I was asked to check why some find commands were skipping hidden folders and I figured out that issue was in having wildcard at the end of the path like here: find /path_to_folder/* Output ...
-1
votes
3answers
85 views

How to "run 'dmesg' using only the 'find' command"? [closed]

For one of my lab assignments, I need to "run dmesg using only the find command". I have been trying to look and can't find anything probably because its not the way it's supposed to be used....
1
vote
1answer
37 views

Find a file by pattern but ignore others with similar patterns

I have a directory that has subdirectories in it and I need to get the names of some of these subdirectories but there is one with a similar pattern as them that I want to ignore. For example, if the ...
3
votes
2answers
540 views

Find returns same path twice, but truncated

I am running this find command: find $HOME * -depth -type d -iname *bowtie* | grep "bowtie*-*1[^2]" My expected out put is: /home/user/Documents/scripts/bowtie1.3.0-linux-x86_64 /home/user/...

1
2 3 4 5
64