I have two files containing users, but the lists differ. My goal is to take all the users in file1 and remove them from file2. What would be a simple method for completing this?

-moktod

I have no idea how you would do that in Shell Scripting. I could do it in Perl fairly easily... but I think that might be a little bit of a task in Shell.

I should be able to iterate through file1 and say if a match is found in file2, do some sed removal of that line, right? I suppose I would need the correct sed command.

-moktod

I have no idea how you would do that in Shell Scripting. I could do it in Perl fairly easily... but I think that might be a little bit of a task in Shell.

How would you accomplish this in perl?

-moktod

Well, This isn't the perl forum, so I probably shouldn't have posted that in here (my apologies). In Either language, though, I would read the first file, and compare it to each line of the second file. In perl, I'd read both into arrays, loop through and compare the arrays.

Attached Is How I would do this with a Perl Script. I'm working on doing it in bash shell right now also... but it seems a bit more complicated to me.... maybe I just like the feel of perl better, and so it flows more naturally and easy to me... but I'll keep giving it a go in Shell.

I have two files containing users, but the lists differ. My goal is to take all the users in file1 and remove them from file2. What would be a simple method for completing this?

-moktod

look into 'man comm'

commented: Nice. +1

Wow... Nice!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.