Re: [lfs-support] Using 'find' to Help Make Package Users Simpler
On 10/16/2013 03:59 PM, Dan McGhee wrote: > On 10/16/2013 03:15 PM, Pierre Labastie wrote: >> I've never tried two -exec directives in find, sorry. What I know is that >> xargs is more flexible, >> and I recommand that you insist on having it work. >> It could be something similar to: >> find... -print| xargs -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> >> installdirs.lst' >> more robust: >> find... -print0 | xargs -0 -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> >> installdirs.lst' >> >> Good luck >> Pierre > My understanding of -I is that standard input would replace > some string. Would you please tell me if my understanding of -I is > right, and then indicate what I might put in place of "xxx". > > Thanks, > Dan > I had it exactly backwards! -I replaces standard input with a specified string. I used, simply, "file." The command line with "print0" did exactly what I wanted. Maybe I should now learn about aliases instead of writing a one line script. :) Thanks again, Pierre. You really helped. Dan -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
Re: [lfs-support] Using 'find' to Help Make Package Users Simpler
On 10/16/2013 03:15 PM, Pierre Labastie wrote: > I've never tried two -exec directives in find, sorry. What I know is that > xargs is more flexible, > and I recommand that you insist on having it work. > It could be something similar to: > find... -print| xargs -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> > installdirs.lst' > more robust: > find... -print0 | xargs -0 -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> > installdirs.lst' > > Good luck > Pierre Thank you, Pierre! I now know why I was not successful with xargs. I didn't know about "sh -c". I never really jumped into the examples at the end of the man page. And know I need to really get a firm handle on all the options for xargs so I can use it. I don't understand, though, "-I xxx". First, I don't know what the xxx would mean, and secondly, the way I see it in my limited knowlege, the file name would be the standard input, but what "string" would it be replacing. My understanding of -I is that standard input would replace some string. Would you please tell me if my understanding of -I is right, and then indicate what I might put in place of "xxx". Thanks, Dan -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
Re: [lfs-support] Using 'find' to Help Make Package Users Simpler
Le 16/10/2013 20:43, Dan McGhee a écrit : > [...] > > Here's the find statement: > ) \! -path /usr/src > \! -path /tools -print> > > This statement achieves all the parameters stated above with the > addition that it ignores /tools also. Now I would like to change group > ownership and permissions and redirect the output to installdirs.lst. I > know I could do that using an intermediate file: > > find > tmpfile > chown $(cat tmpfile) > chmod $(cat tmpfile) > tmpfile >> installdirs.lst > rm tmpfile > > But, and here's the real question of this post, can I do this with one > statement? Here's my first idea: > > 'find' | 'chown' | 'chmod' >> installdirs.lst I do not know if chown can read standard input. If it would, the first pipe would work. But the second will never work, since it takes the output off the chown command, not that of find... > > Or, can I use more than one -exec option in 'find'? The statement would > look something like this > > find (stuff) -exec chown :install {} \; -exec chmod ug=rwx, o=rxt {} \; > >> installdirs.lst > > The reason I'm asking this question is that one of my references says > "[-exec] will execute the program once per file while xargs can handle > several files with each process." I've never been successful with xargs > and I don't know if 'find' will, then ignore the second -exec. I > haven't been able to glean anymore from wandering around on the internet > and wading through man pages. > > I have "piped" the output of find only once many times, but I don't know > if the output would survive two pipes. > > I guess that it's just one question after all. Can I use "chained" > pipes or -execs before I redirect? > I've never tried two -exec directives in find, sorry. What I know is that xargs is more flexible, and I recommand that you insist on having it work. It could be something similar to: find... -print| xargs -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> installdirs.lst' more robust: find... -print0 | xargs -0 -I xxx sh -c 'chmod xxx; chown xxx; echo xxx >> installdirs.lst' Good luck Pierre -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
[lfs-support] Using 'find' to Help Make Package Users Simpler
This may come close to or straddle the "off topic" line for this list. I thought I'd ask my question anyway since there are some who use the More Control hint and who run into some of the same frustrations that I do. There is a question about the use of find in this post. If you don't want to read the reasoning behind doing this and some history skip the following three paragraphs. The "install directory" is an important concept in this system. It is a directory in which any package user can write, but that files in it can be changed only by the owner of that file--ug=rwx,o=rxt. The initial set of these directories is listed in a file called "installdirs.lst." This file is used to set the permissions of all directories to which different package users could write. The most frustrating, naggy and "four letter word" evoking event is trying to write to a directory made by a different package user and in which the current package user cannot write. This is the purpose of the auxiliary "install" group. The trick, then, is to identify all the "new" directories from a package and make them "install" directories. This used to be a really "down-in -the-trenches" manual job. Rob Taylor did some great work in scripting the search for new directories. He has a series of 'find' statements that step through the directory tree--/usr, /bin, /lib, et.al.--finding all directories and sending them to "installdirs.lst." He then has a sed command that removes /usr/src/ tree directories--this is the tree in which the package users have their home directories and these should not be group writable. He then has two statements 'chown' and 'chmod' whose input is $(cat installdirs.lst). This system works and is really a nice addition to package users' support. The first 'find' statement re-creates "installdirs.lst" and the remaining 6 append to it. And sed removes /usr/src each time. I thought it would be more "economical" to not over write installdirs.lst each time, and to use 'find' to identify only the new directories, change their group ownership, then their permissions, and finally append them to installdirs.lst. I know that find is powerful enough to ignore /usr/src, so the need for the sed statement goes away. Here's the find statement: ) \! -path /usr/src \! -path /tools -print> This statement achieves all the parameters stated above with the addition that it ignores /tools also. Now I would like to change group ownership and permissions and redirect the output to installdirs.lst. I know I could do that using an intermediate file: find > tmpfile chown $(cat tmpfile) chmod $(cat tmpfile) tmpfile >> installdirs.lst rm tmpfile But, and here's the real question of this post, can I do this with one statement? Here's my first idea: 'find' | 'chown' | 'chmod' >> installdirs.lst Or, can I use more than one -exec option in 'find'? The statement would look something like this find (stuff) -exec chown :install {} \; -exec chmod ug=rwx, o=rxt {} \; >> installdirs.lst The reason I'm asking this question is that one of my references says "[-exec] will execute the program once per file while xargs can handle several files with each process." I've never been successful with xargs and I don't know if 'find' will, then ignore the second -exec. I haven't been able to glean anymore from wandering around on the internet and wading through man pages. I have "piped" the output of find only once many times, but I don't know if the output would survive two pipes. I guess that it's just one question after all. Can I use "chained" pipes or -execs before I redirect? Anyone have any comments or suggestions. In the meantime, I'll just play. What can I do, but screw things up, and I've done that twice this week already. Sorry for the long post. I appreciate your patience. Thanks, Dan -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page