find

macOS find with "-f path" doesn't work?

macOS find with "-f path" doesn't work? man find: -f path: Add path to the list of paths that will be recursed into. This is useful when path begins with a character that would otherwise be interpreted as an expression, namely “!” , “(” and “-”. But why find ./test-folder -type f -name ‘*.txt’ works, …

Total answers: 2

Delete certain files from specific date in linux

Delete certain files from specific date in linux I need a command how I can delete files from a folder with specific date. Like I want to delete files before 20 April from a folder on /home/FTP and file types are mp4. Asked By: White hat Mahmud || Source This option "-mtime +12" specifies the …

Total answers: 2

How can I use find paired with grep to delete files

How can I use find paired with grep to delete files I am attempting to write a script to delete files from a directory. find /home/docs/* -name "*.log" -type f -print -exec rm -f {} ; The above works however I need to use grep to target directories using grep. When I put grep I …

Total answers: 3

What are the file size options for "find . -size" command?

What are the file size options for "find . -size" command? I found out that to look for file size in bytes, I use ‘c’. So I can look for file size with 1000 bytes by using: find . -size 1000c But what about different kind of size such as Mb, Gb or even bits? …

Total answers: 3

How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression?

How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression? For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all directories: …

Total answers: 2

Moving and organizing files with find

Moving and organizing files with find I have a folder on a Debian GNU/Linux 12 (bookworm) x86_64 Server used as a NAS/Homelab server with a lot of files from a surveillance camera. MDAlarm_20240301-091804.jpg … MDAlarm_20240316-153813.jpg MDAlarm_20240327-183713.jpg If I try to move the files with (eg) mv snap/*.jpg /path/to/dest/2024/03 I get -bash: /usr/bin/mv: Argument list too …

Total answers: 1

Using find with regular expression

Using find with regular expression I try to understand how to use the find command with regular expressions (macOS 14.4.1, Zsh 5.9). I have a directory with files such as note-red.png, note-yellow.png, (and other colors), folder-red.png, folder-yellow.png, (and other colors), but the following commands don’t show any results when executed in that folder. What I’m …

Total answers: 1

Find files that are sorted before a given file

Find files that are sorted before a given file I have a directory with a number of files. Example: aaa.txt bbb.txt ccc.txt ddd.txt Given an arbitrary string (not necessarily the name of one of the files), I want to find all the files that are sorted before that string (in a normal alphabetical sort). Example: …

Total answers: 6

Is there any way to get `find` not to quote the result of -printf

Is there any way to get `find` not to quote the result of -printf I want to use the find command with -printf ‘%h’ to print the leading directories, separated by the nul character. Since I am using , I don’t need, and don’t want find to quote the results, as described in the "UNUSUAL …

Total answers: 1

linux find and rename items with backslash not working as expected

linux find and rename items with backslash not working as expected I have tried a couple of approaches to find and rename some files that hold a backslash (mind you these files generated from a web app do not have the quoets) in a directory. I’ve tried with find and substitutions but they seem to …

Total answers: 2

Find all the folders that are concealed using 'chflags'

Find all the folders that are concealed using 'chflags' I have concealed some folders on my laptop using chflags: chflags hidden hide-me And I don’t remember where exaclty these folders are located. How is it possible to find all of them? (Probably by using find and/or grep.) Asked By: jsx97 || Source Something like that: …

Total answers: 1

Why doesn't the given command mask other lines?

Why doesn't the given command mask other lines? Command: sudo find / -name miniedit.py -print | grep -i "miniedit" | tail -1 Output: find: ‘/proc/10031/task/10031/net’: Invalid argument find: ‘/proc/10031/net’: Invalid argument find: ‘/run/user/1000/gvfs’: Permission denied find: ‘/run/user/1000/doc’: Permission denied /usr/share/doc/mininet/examples/miniedit.py Expected output: /usr/share/doc/mininet/examples/miniedit.py What am I doing wrong? Asked By: kesarling He-Him || Source You …

Total answers: 1

find with execdir, pipe redirection evaluated too early (quote issue?)

find with execdir, pipe redirection evaluated too early (quote issue?) I use multiple GitHub accounts at work, so I need to modify the remote url to add my work account. I have figured out the recursive find -execdir, and how to get/sed/set the remote url, but I cannot combine them. I tested the find command …

Total answers: 1

Add files from "bash find" to 7z archive

Add files from "bash find" to 7z archive I did quite a bit of searching before asking this! (Even so I’m expecting to have a duplicate pointed out). So I collect a bunch of files, e.g.: find . -name "2020-*" … is there some way to "pipe" all these files into a .7z archive? (NB …

Total answers: 1

List all files in a directory, recursively, sorted by modification date

List all files in a directory, recursively, sorted by modification date The main answer of Sort the files in the directory recursively based on last modified date gives a method to list all files in a directory, recursively, sorted by modification date: find -printf "%TY-%Tm-%Td %TT %pn" | sort -n However it doesn’t list only …

Total answers: 1