Results 1 to 4 of 4
HI Everyone,
I have a bash scripting question here, that's been giving me trouble.I have two files here with names in them. I need to create two new files by ...
- 09-24-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 10
Finding lines not common in both files
HI Everyone,
I have a bash scripting question here, that's been giving me trouble.I have two files here with names in them. I need to create two new files by comparing these files.
Each file will have only unique names from the file. In other words, one file contain ONLY unique names in file1. Then the next file contain only the unique names in file2.
file1
############
ruby
heather
ethel
alicia
melody
rosene
file2
############
heather
alicia
carla
ruby
gloria
So when the script has run, I'd have two files - unique1 & unique2.
unique1
############
melody
rosene
unique2
############
carla
gloria
I'd like to stay with bash scripting if at all possible. I've tried the DIFF function, but that outputs all differences to the same file.
Any ideas for me?
Thanks so much,
Dave
- 09-25-2008 #2Just Joined!
- Join Date
- Sep 2008
- Posts
- 20
grep -v -f file1 file2 > unique2
grep -v -f file2 file1 > unique1
btw, ethel should be in unique1, right?
- 09-25-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 10
- 09-25-2008 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Look at the comm command - this is what it's designed for.


Reply With Quote
