Re: how to select files not in a list

From: -linux_lad (john_at_linuxlad.org)
Date: 04/28/04


Date: Wed, 28 Apr 2004 08:42:25 -0700

Carli Fuchs wrote:

> I have two lists, one list holds actual users, another holds a listing of
> home directories. I want to remove the directories that are not in the
> actual users list. I have tried diff, comm, and uniq, but I cannot get just
> a list of directories of people who are not on the actual users list. Am I
> approaching this task wrong? My approach is to list all folders (they are
> named the same as the accountholder), and compare the folder names to the
> list of people who are current account holders. I was thinking that would
> give me a list of people who had folders but did not have accounts, and then
> I can delete those folders. Is there another way to do this?
>
> tia
> c.f.
>
>

If I read and understood this correctly, you want to compare two files
and perform some kind of action (like rm -rf) on the lines that are in
one list but not the other? If so, try this:

file1 = your listing of valid users
file2 = your listing of home directories

comm -3 file1 file2

This will spit out folder names that are NOT in file1, which should be
the stuff you want to remove...assuming that all valid users have a home
dir on list2. Pipe them to a file, then loop through that file. I'm
going off the top of my head, so test this first.

--
-linux_lad
To verify that this post isn't forged, click here:
http://www.spoofproof.org/verify.php?sig=07083a9024530b20bdd9ef8b38fc6e79


Relevant Pages

  • Re: Hiding other users home folders
    ... Windows can't work like Netware did. ... Create user home directories with appropriate permissions in here. ... HOME - and it has all of thier home folders inside of it. ...
    (microsoft.public.windows.server.setup)
  • regarding the samba setup
    ... ,linux and unix clients and few of the users uses windows as well as ... able to see their home directories and other folders through ... network neighbourhood can see their home directories and other ...
    (Fedora)
  • Re: Proper way to do shares
    ... >> have shared folders, so we have about 500 of those. ... > You don't need to share the home directories individually unless you have ...
    (microsoft.public.windows.server.networking)
  • Re: Proper way to do shares
    ... >> have shared folders, so we have about 500 of those. ... > You don't need to share the home directories individually unless you have ...
    (microsoft.public.windows.server.networking)
  • Re: how to select files not in a list
    ... >I have two lists, one list holds actual users, another holds a listing of ... >home directories. ... My approach is to list all folders (they are ... >named the same as the accountholder), and compare the folder names to the ...
    (comp.unix.shell)