Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Set difference between sets of files



Hi all,

I'm pretty new to Zsh. I have a question:

I would like to compute the set difference between two sets of files - that is,
obtain a list of files found in one set and not in the other.

For instance, say I have two directories - master/ and backup/ - containing
(mostly) identical files. I would like to remove from backup/ all files which
have been removed from master/. I would like to achieve this by doing something
like this:

    cd master/
    MASTER_FILES=(**/*(.))
    cd ../backup
    BACKUP_FILES=(**/*(.))
    TO_REMOVE=<set difference between BACKUP_FILES and MASTER_FILES>
    rm -f $TO_REMOVE

I know that this can be done by writing both sets to temporary files, sorting
them, and using the standard Unix command "comm", but is there an elegant way
to do this from within Zsh?

Sincerely yours,

Itai

--
All nationalists have the power of not seeing resemblances between
similar sets of facts.
- George Orwell, "Notes on Nationalism"



Messages sorted by: Reverse Date, Date, Thread, Author