IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Who uses a newline in a filename?
Someone with limited permissions who is attempting to get local root access, that's who. :-P

Anyways I was expecting you to come back with the fact that yours is faster. By a lot.

Cheers,
Ben
a very rich person should leave his kids enough to do anything but not enough to do nothing. -- Warren Buffett
New Why?
I'm guessing yours is looping through an array, all of which has to stay in memory simultaneously, while his iterates through a list of files with only one filename|node in memory at a time. Am I close?
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New 'find' starts a process for each iteration of exec
Whereas the form that Mike used will collect all the filenames, then feed them to chmod at one time.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New I don't follow
I would expect if I watched top while Ben's is running, I'd see one instance of find and one instance of chmod that would live until everything was done. With Mike's I'd expect to see one instance of find which would finish as soon as the file list is created, and a new instance of chmod would appear for each file.

So if process creation was the bottleneck, I'd expect Mike's to be faster.
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New Exact opposite.
find -exec chmod calls 'chmod somefile' for each file it finds. It has to, because it can't know how that particular executable works. In order to keep one around and use it, some sort of piping would be necessary.

find | xargs chmod will instead gather up all the file names, turn them into a single string via xargs, then pass that string as args to chmod. Run 'find . -type f | xargs' sometime to see what it does.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Not necessarily a *single* string
xargs will break up long lists so that you fit inside the limits for the length of a command line.

Cheers,
Ben
a very rich person should leave his kids enough to do anything but not enough to do nothing. -- Warren Buffett
New Okay, makes sense
In my limited use of scripting, I must have gotten lucky in that I found piping more clear conceptually than calling -exec or other optional parameters on various commands.
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
     Quick bash script help needed - (inthane-chan) - (12)
         find . -type f -exec chmod 774 '{}' #untested -NT - (ben_tilly) - (11)
             find . -type f -print | xargs chmod 774 #untested/same thing -NT - (Yendor) - (9)
                 Mine is safer (newlines in filenames) -NT - (ben_tilly) - (8)
                     Mine is bigger - (Yendor) - (7)
                         Who uses a newline in a filename? - (ben_tilly) - (6)
                             Why? - (drewk) - (5)
                                 'find' starts a process for each iteration of exec - (admin) - (4)
                                     I don't follow - (drewk) - (3)
                                         Exact opposite. - (admin) - (2)
                                             Not necessarily a *single* string - (ben_tilly)
                                             Okay, makes sense - (drewk)
             Thanks. - (inthane-chan)

At least.. the Lx stuff written *here* is nicely done in English.
46 ms