17 Jan
2002
17 Jan
'02
11:27
On Thu, 2002-01-17 at 11:16, Matt Johnson wrote:
Hi all,
How would I write a script that only affected certain groups?
Trying to think of an example, how could I run:
rm /home/*/file_to_delete
only on the home directories of folk who belong to the 'pupil' group.
No point recursing down these trees - getting a list of home directories for that group would be something like awk -F: '($4 == 25) {print $6}' /etc/passwd change the 25 to the numeric group id of your wanted group.
One command I run is find /home -name '*' -maxdepth 1 -exec cp /home/template/file_to_copy '{}'/new_file ';'
Can I build a "where user is in group 'pupils'" into that somehow?
you could add a -group pupils to the condition (ie straight after -maxdepth 1). Nigel.