Script to move into each home and delete all .g* folders
Mika Pflüger
mail at mikapflueger.de
Tue Nov 10 23:11:52 GMT 2009
Hi,
Am Tue, 10 Nov 2009 14:29:10 -0700
schrieb Jim Christiansen <jim.c.christiansen at gmail.com>:
> What I need to do is find a script that will:
>
> cd into each student home
> rm -rf .g*
> cd back out
> cd into the next student home and repeat all the way through the home
> dir
Before I make any suggestions, please consider:
.g* would match an awful lot of other stuff: Private keys
in .gnupg-folders, backups/versioning in .git-folders and similar.
Maybe you should rather make a list of what to delete
Make a backup, then try:
1. If you want to delete all those folders in all user's home
directories (not only student's):
rm -rf /home/*/.g*
Just type it into a terminal as root. But it is pretty brutal, as
stated above
2. If you want to delete only the student's folders:
rm -rf /home/{$(cat /etc/group|grep students|cut -d ':' -f4)}/.g*
Replace students with the name of the group of your students. Still
pretty brutal, but works if the group has more than one member.
But, you should use a better wildcard:
rm -rf /home/*/.{gnome,gnome2,gconf}
would be way better already. Note all user's settings will still be
lost, but better than losing their private keys.
So for all the students this would read:
rm -rf /home/{$(cat /etc/group|grep students|cut -d ':' -f4)}/.{gnome,gnome2,gconf}
of course you can add other offending stuff into the
{gnome,gnome2,gconf} list.
And PLEASE: Before you run this, make a backup and try the command
replacing "rm -rf" with "ls" -- it will show you what will be deleted.
Check the list carefully, as I can't guarantee those one-liners are
really what you need and if I understood you correctly.
Note that with many users you might run into the "command line too
long" error. Then we have to think about something else involving
loops or "find"s
Greetings,
Mika Pflüger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/edubuntu-users/attachments/20091111/3653b580/attachment.pgp
More information about the edubuntu-users
mailing list