Re: how to select files not in a list
From: -linux_lad (john_at_linuxlad.org)
Date: 04/28/04
- Next message: Charles Demas: "Re: how to select files not in a list"
- Previous message: Ed Morton: "Re: how to select files not in a list"
- In reply to: Carli Fuchs: "how to select files not in a list"
- Next in thread: Charles Demas: "Re: how to select files not in a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Charles Demas: "Re: how to select files not in a list"
- Previous message: Ed Morton: "Re: how to select files not in a list"
- In reply to: Carli Fuchs: "how to select files not in a list"
- Next in thread: Charles Demas: "Re: how to select files not in a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|