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 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
Sure, you could do that. It just seems like it would be more work in my opinion. Here is the link a sed man page: http://www.rt.com/man/sed.1.html, and a sed tutorial: http://www.selectorweb.com/sed_tutorial.html, and here is info on reading files in Bash: http://www.linuxgazette.com/node/8384.
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'
Wow... Nice!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.