[TriLUG] OT - Help merging multiple files into a single file

Robert Dale robdale at gmail.com
Thu Nov 8 08:54:40 EST 2007


On Nov 7, 2007 4:09 PM,  <howard.x.boyd at gsk.com> wrote:
> Could someone please suggest a unix command or utility that will help me
> merge the contents of multiple files into a single file. We currently have
> 200+ AIX systems with a /etc/sudoers file on each server. The contents of
> these files may or may not be the same. The goal is to examine the
> contents of all the files and merge them into a single master sudoers file
> that will be maintained and periodically pushed out to all the servers.
> Would appreciate any suggestions or ideas on how best to accomplish this
> task. Thanks,

What are the rules?

What determines a command match?
Are aliases LCD or additive?
How to resolve conflicts?

You certainly could do "cat * | sort | uniq > /tmp/newsudoers" (Andrew
Perrin) and then manually merge from there.  To cut down on whitespace
differences, you could run sed on all the files to remove leading,
trailing, and any excess whitespace in between.

I imagine it wouldn't be too hard to write a perl script to do per
field merging.

-- 
Robert Dale



More information about the TriLUG mailing list