18 Jan
2002
18 Jan
'02
13:57
On Fri, 18 Jan 2002, Matt Johnson wrote: > > You could try something like > > "find /home -group pupil"... > Hmm. I've got a bit stuck. I should have said the > words 'RedHat'. It uses User Groups as primary groups > - so all these home directories do not belong to the > 'pupil' group. Any other ideas? I'm playing with cat, > grep, sed and find to try to extract the names next to > the pupil group in /etc/groups - but I'm messing up > the pipes and the '>' etc. I am also trying to work > out how to strip off useless info from a line from > /etc/group, and then run all words between commas > individually into find. I'm still experimenting. > Please let me know any pointers, or even better - give > examples. The one-liner: perl -ne 'print join(" ", split(",",$_) ) if s/^pupil:.*:(.*)$/$1/' /etc/group will give you a space-separated list of names. Change the first parameter to join (the " ") to something else if you want another separator. For example, perl -ne 'print join("\n", split(",",$_) ) if s/^pupil:.*:(.*)$/$1/' /etc/group would give you one name per line. > I think the scripting (potential - for me) of Linux is > _such_ a big selling point. I can see what I want to > do with it, and it's great when you figure out a > little script to go off and do it for you. It is _so_ > powerful, and makes admin tasks a breeze (once you've > figured out the syntax). Learn about Perl and regular expressions! They're not quite as horrible and line-noisy as they appear at first. :-) Michael