[thelist] Milwaukee Beervolt tonite

Daniel J. Cody djc at starkmedia.com
Tue Apr 10 11:59:10 CDT 2001


5:30 at the Milwaukee Ale House on Water.. We've got 4 possibles coming
so far, and 2 for sures. Everyone is invited and evolt tshirts for all!
:)

<tip type="chown'ing huge directory listings">

Lets say you have a directory with 20 subdirectorys, /www/1 /www/2
/www/3 and so on. You need to change the owner of the data directory
under each of them to 'foo',but dont want to do it manually.(who does
anything manually witha shell? :) So, we can use a little awk script to
put it together for us:

[root at server /www]# ls -l | awk '{print "chown nobody "$9"/data"}' >
this.sh

That will grab a directory listing(ls -l) then pass it to awk who will
prepend the 'chown nobody' command to each subdirectory in the /www
directory(from the ls -l, the $9 is the ninth column in that output),
and then append '/data' on the end of that. Finally, it will output that
into a textfile called this.sh which will look like this when you're
done:

chown nobody 1/data
chown nobody 2/data
chown nobody 3/data
etc...

Simply run the this.sh file as a bash script and it will walk through
each of the directories for you, chown'ing them to nobody, saving you
time for more important things like beervolts :)

</tip>

.djc.




More information about the thelist mailing list