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
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 153769

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

0
votes
You're improperly using find and needlessly creating a shell loop (it hurts to read!), because you can (should) run ffmpeg directly from inside find: find . -type f -name *.webm \ -exec sh -c 'echo …
answered Mar 6 '18 by user1404316
25
votes
If all the files to be processed are in the same folder, you don't need to use find, and can make do with native shell globbing. for foo in *.txt ; do mycommand "${foo}" -o "${foo%.txt …
answered Jan 29 '18 by user1404316
0
votes
According to the man page, the -regex option is a match on the entire path, ie. the entire file name and also the entire directory-path portion, so you would need to precede your regex with .*. There …
answered Mar 9 '18 by user1404316
1
vote
find . -type f ! -name "_*" -printf "%f\n" The printf with %f is a GNU extension of POSIX find. …
answered Feb 13 '18 by user1404316
1
vote
Depending upon how I interpret your question (see comments), your solution would be either: find $root_dir -name $file_name -exec pidof {} \; or: find $root_dir -name $file_name -exec fuser … a file using the less command, pressed C-z to stop it and put it in the background, and ran find /usr/bin -name less -exec pidof {} \;. To test it for the second alternative, I created a data file ~/test.txt, ran less ~/test.txt, then C-z, followed by find ~ -name test.txt -exec fuser {} \;. …
answered Feb 13 '18 by user1404316
0
votes
The correct idiom for avoiding the "permission denied" error messages is: find <root-path> ! -readable -prune -o <rest of your find arguments> Applying that to your original homework answer would … yield: find / ! -readable -prune -o -type f -name "*.log" That should satisfy your requirement to "assemble a simple and smart command". It also fulfills the requirement "that doesn't just blindly …
answered Feb 15 '18 by user1404316
2
votes
You can perform basically any single operation or list of operations within find's -exec option, so why not untar each archive directly within find -exec? For complex commands, it's common to use the … something like: -exec sh -c 'tar xvf "$1" -C "$(dirname $1)"' sh {} ';' The idea is that this idiom brings all of your favorite shell's features within the find command. (And, yes, you could use bash …
answered Feb 15 '18 by user1404316
0
votes
find includes an option -printf which allows you to format what to output about your results, and how to output them. One of possibilities listed in the documentation for that option (see the man … page) is %s for a file's size in bytes. Thus, you can add to your find command something like `-printf "%s %p\n". …
answered Mar 15 '18 by user1404316