Re: how to select files not in a list

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 04/29/04


Date: Thu, 29 Apr 2004 19:37:45 +0100

2004-04-28, 08:24(-07), Carli Fuchs:
> 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?

zsh/bash/ksh:

set -f
cd /home
IFS="
"
echo rm -rf -- $(comm -1 -3 <(cut -d: -f1 /etc/passwd|sort) <(ls))

Remove "echo" when you're OK.

-- 
Stéphane                      ["Stephane.Chazelas" at "free.fr"]


Relevant Pages

  • Re: multi folder view - does this exist?
    ... If all you want are simple lists then just do that, ... than's available could be to have 2 x 2 listviews with a combobox at the top ... fill all the combo boxes with all the folders you are ... Explorer 8 where you just click a tab to view that folder. ...
    (microsoft.public.vb.general.discussion)
  • Re: Cant Get Addresses from OL
    ... All Address Lists -- Empty ... Public Folders -- Empty ... Outlook Address Book -- Empty ...
    (microsoft.public.outlook.general)
  • Re: Cant Get Addresses from OL
    ... All Address Lists -- Empty ... Public Folders -- Empty ... Outlook Address Book -- Empty ...
    (microsoft.public.outlook.contacts)
  • Tips & Tricks re: prep for F9
    ... the cruft out of my /home partition. ... Fedora version changes and/or re-installs and trying out different ... yum --list or rpm -qa give long lists that are ... Is there a way to flag unneeded folders for later 'rm' removal? ...
    (Fedora)
  • Re: Copying data from multiple files
    ... through all the files in the folders. ... That line lists all the other file's ... TEST 1 is the active file when I start the macro. ... probability that additional source files will be added over time. ...
    (microsoft.public.excel)