Carlos, et al -- ...and then Carlos E.R. said... % % The advantage with xargs is, I assume, that it does % % ghgrp args----verylonglinewithathousandfilesatonce It does. You call your command fewer times by sending it lots of args each time. % % Considering that I have 10000 photos in at least two formats, that's % many files to change and takes minutes to run. Yep. Worse, you want to do multiple things to each file, which is where it gets really interesting. % % I know how to do that calling another script. Maybe the same script with % a switch. But not without a helper script. The real trick is capturing the input args to reuse across multiple commands, because for FILE do chmod X $FILE chgrp Y $FILE done is just as painful. I whipped up a little test directory of 90k files davidtg@gezebel:~> ls /var/tmp/X | head -5 ; ls /var/tmp/X | tail -5 ; ls /var/tmp/X | wc -l 010000 010001 010002 010003 010004 099995 099996 099997 099998 099999 90000 and a little script davidtg@gezebel:~> cat /tmp/X.sh #!/bin/sh CM() { ### show what we got CMWC=`echo $* | wc -cw` printf "CMWC $CMWC\t1 = $1\n" # begin code here chmod 000 $* } CG() { ### show what we got CGWC=`echo $* | wc -cw` printf "CGWC $CGWC\t1 = $1\n" # begin code here chgrp users $* } # grab command line and see what we have WC=`echo $* | wc -cw` printf "PID $$\n WC $WC\t1 = $1\t2 = $2\t3 = $3\n" # call chmod function shift ### drain an arg to prove function input CM $* # call chgrp function shift ### drain an arg to prove function input CG $* echo '' to demo. You can see that I grab the number of chars and words on the command line and then strip off an arg as I pass the list to each function. Here is a partial run davidtg@gezebel:~> find /var/tmp/X -type f -print0 | xargs -0 /tmp/X.sh PID 20310 WC 7281 131058 1 = /var/tmp/X/010000 2 = /var/tmp/X/010001 3 = /var/tmp/X/010002 CMWC 7280 131040 1 = /var/tmp/X/010001 CGWC 7279 131022 1 = /var/tmp/X/010002 PID 20322 WC 7281 131058 1 = /var/tmp/X/017281 2 = /var/tmp/X/017282 3 = /var/tmp/X/017283 CMWC 7280 131040 1 = /var/tmp/X/017282 CGWC 7279 131022 1 = /var/tmp/X/017283 PID 20335 WC 7281 131058 1 = /var/tmp/X/024562 2 = /var/tmp/X/024563 3 = /var/tmp/X/024564 CMWC 7280 131040 1 = /var/tmp/X/024563 CGWC 7279 131022 1 = /var/tmp/X/024564 PID 20347 WC 7281 131058 1 = /var/tmp/X/031843 2 = /var/tmp/X/031844 3 = /var/tmp/X/031845 CMWC 7280 131040 1 = /var/tmp/X/031844 CGWC 7279 131022 1 = /var/tmp/X/031845 ^C that I cut short just because I didn't want to paste the full 60-70 lines here :-) Now ... How many of your files have evil spaces in them to mess up the calls to the functions? I used -print0 and -0 but didn't really put any smarts in the demo script ... mostly because I didn't think of it when running my files loop :-) You may want to play with $@ instead to try to retain formatting. Meanwhile, you could very likely also put all of your find logic inside this script to generate the list and just pass it a list of directories to process if you're still worried about extra scripts. You need to call sudo in there somewhere, and since you like to list commands explicitly I'd lean toaard sudo /path/to/fixit.sh /dir/1 /other/2 /elsewhere/3 for just one sudo call. YMMV, of course :-) % % -- % Cheers / Saludos, % % Carlos E. R. % (from 15.1 x86_64 at Telcontar) HTH & HAND :-D -- David T-G See http://justpickone.org/davidtg/email/ See http://justpickone.org/davidtg/tofu.txt -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org