[PLUG] shell scripting problem
D. Cooper Stevenson
cooper at linux-enterprise.net
Fri Jun 7 01:22:31 UTC 2002
On Thu, 2002-06-06 at 17:52, Matt Alexander wrote:
> I have about 200 names in /etc/group that I want to remove. They're all
> under a generic "users" group.
#***********Cut Here***************************
#!/bin/bash
input_file=your_name_list
passwd_file=/etc/passwd
shadow_file=/etc/shadow
temp_passwd_file=/tmp/passwd
temp_shadow_file=/tmp/shadow
cat $input_file | while read name
do
sed /$name/d $passwd_file > $tmp_passwd_file
sed /$name/d $shadow_file > $tmp_shadow_file
done
#**********End Script***************************
Make the script above executable.
Check out the password and shadow files in the /tmp directory to see
that the results were satisfactory.
MAKE SURE YOU DELETE THE TEMP FILES AFTER YOU ARE FINISHED AND BE
*CERTAIN* THE PERMISSIONS ON THE PERMANENT PASSWORD AND SHADOW FILES ARE
CORRECT!
-Cooper
I have a file that contains the names that I
> want to remove, and I'm looking for a wizbangwowzerz *nix way to read in
> all those names and delete them from the group file. I'll also need to
> delete the comma after each name.
>
> I'm thinking something along these lines...
>
> for name in `cat namefile`;do sed s/$name,// group;done
>
> Obviously this won't work, but that's sort of where I'm thinking now...
> pull each name and the following comma out of the group file and then
> somehow magically rewrite the group file when I'm done.
>
> Any suggestions?
> Thanks,
> ~M
>
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
More information about the PLUG
mailing list