Subscribe: Comments on My SysAd Blog -- Unix: Using the Common UNIX Find Command
http://www.mysysad.com/feeds/5845080010673126337/comments/default
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
article find  command line  command  depth  exec  file  files command  files  find command  find man  find  line built  man page  page 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Comments on My SysAd Blog -- Unix: Using the Common UNIX Find Command

Comments on My SysAd Blog -- Unix: Using the Common UNIX Find Command





Updated: 2017-08-10T07:44:05.379-07:00

 



Good article on Find Command

2012-01-19T00:17:15.113-08:00

Good article on Find Command



Nice article. here is my way of using find comma...

2011-04-08T08:44:45.468-07:00

Nice article. here is my way of using find command in Unix hope this would be useful for you.



Hi,This Page is awesome.I found all the details th...

2009-02-11T17:41:00.000-08:00

Hi,

This Page is awesome.I found all the details that i needed for find



I was looking for non-reccursive find. this do...

2008-04-16T18:59:00.000-07:00

I was looking for non-reccursive find. this doesn't help. it's still doing reccursuive search



## a non-recursive file listing#find /var/spool/mq...

2008-02-11T14:24:00.000-08:00

#
# a non-recursive file listing
#
find /var/spool/mqueue/* -type d -prune -o -type f -print



You have to be careful when you remove things.You ...

2007-10-02T12:19:00.000-07:00

You have to be careful when you remove things.
You say remove files which name is core, but lacks the "-type f" option:
find . -name "core" -exec rm -f {} \;
The same for the example with directories named "junk". Your command would delete any type of files called junk (files, directories, links, pipes...)

I did not know about "-mount", I've always used "-xdev".
Another nice feature, at least in linux find, is the "-exec {} \+", which will fork only once.

Nice good article, and also the comments!



instead of usingfind ./ -name blahI find it better...

2007-08-20T00:37:00.000-07:00

instead of using
find ./ -name blah
I find it better to use the case-insentive form of -name, -iname:
find ./ -iname blah



" Josh said... From the find(1) man page: -e...

2007-08-13T00:59:00.000-07:00

" Josh said...

From the find(1) man page:

-exec command {} +
This variant of the -exec option runs the specified command on the selected files, but the command line is
built by appending each selected file name at the end; the total number of invocations of the command will
be much less than the number of matched files. The command line is built in much the same way that xargs
builds its command lines. Only one instance of â{}â is allowed within the command. The command is exeâ
cuted in the starting directory."

Apparently, "-exec" seems to be implementation specific, which is another good reason to avoid using it, since it means that performance factor will differ from implementation to implementation.

My point is, by using `xargs`, one assures that the script / command will remain behaving the same across different UNIX(R) and UNIX(R) like operating systems.

If you had to choose between convenience and portability+consistency, which one would you choose?



the recursive finds were useful

2007-08-09T20:03:00.000-07:00

the recursive finds were useful



From the find(1) man page:-exec command {} + ...

2007-08-07T12:53:00.000-07:00

From the find(1) man page:

-exec command {} +
This variant of the -exec option runs the specified command on the selected files, but the command line is
built by appending each selected file name at the end; the total number of invocations of the command will
be much less than the number of matched files. The command line is built in much the same way that xargs
builds its command lines. Only one instance of â{}â is allowed within the command. The command is exeâ
cuted in the starting directory.



ux-admin, I'm on the road right now. Please send ...

2007-07-09T17:50:00.000-07:00

ux-admin, I'm on the road right now. Please send me an email at info@esofthub.com. I'll get back to you ASAP. Thanks Roy



When two things happen:- you tell me what I should...

2007-07-08T13:08:00.000-07:00

When two things happen:

- you tell me what I should write about

- I can squeeze enough time for more than just dropping a few quick notes.



ux-admin, as usual, that was a great comment. Than...

2007-07-07T16:14:00.000-07:00

ux-admin, as usual, that was a great comment. Thanks.

So when are you going to do a guest post on My SysAd Blog? :) Roy



Oops, the last command should have beenfind / -mou...

2007-07-07T10:37:00.000-07:00

Oops, the last command should have been

find / -mount -depth \( -type f -o -type l \) -print ...



Avoid using "-exec {}", as it will fork a child pr...

2007-07-07T10:34:00.000-07:00

Avoid using "-exec {}", as it will fork a child process for every file, wasting memory and CPU in the process. Use `xargs`, which will celeverly fit as many arguments as possible to feed to a command, and split up the number of arguments into chunks as necessary:

find . -depth -name "blabla*" -type f | xargs rm -f

Also, be as precise as possible when searching for files, as this directly affects how long one has to wait for results to come back. Most of the stuff actually only manipulates the parser rather than what is actually being searched for, but even there, we can squeeze some performance gains, for example:

- use "-depth" when looking for ordinary files and symollic links, as "-depth" will show them before directories

- use "-depth -type f" when looking for ordinary file(s), as this speeds up the parsing and the search significantly:

find . -depth -type f -print | ...

- use "-mount" as the first argument when you know that you only want to search the current filesystem, and

- use "-local" when you want to filter out the results from remote filesystems.

Note that "-local" won't actually cause `find` not to search remote file systems -- this is one of the options that affects parsing of the results, not the actual process of locating files; for not spanning remote filesystems, use "-mount" instead:

find / -mount -depth \( -type f -o -type s) -name "blabla" -print ...