help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Comparing arrays


From: Jerry
Subject: [Help-bash] Comparing arrays
Date: Sun, 31 Mar 2013 15:34:37 -0400

This is probably a pretty easy task, however, I have not been able to
find an eloquent way of doing it.

Using Bash-4.x, I have created two arrays.

declare -a New_Files    # Contains a list of files
declare -a Old_Files    # Contents of a directory

The "New_Files" array gets loaded with a group of files that are to be
checked against the existing files in a directory. The existing files
in the directory are loaded into the "Old_Files" array.

Now, what I am attempting to do is check the list of existing files
"Old_Files" against the list of "New_Files". If any of the files in
"Old_Files" does not exist in the "New_Files" list, it is to be
deleted. I have come up with some very laborious methods of doing this,
but I am sure that there has to be a simpler way. I would like to make
this a function also so I could call it from anywhere in the script.

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________




reply via email to

[Prev in Thread] Current Thread [Next in Thread]