Compare two files and send common strings to another file
Posted: 19 Sep 2016 18:23
I have two text files and wanted to compare them and send the common strings to another file
There will be only one word per line. Strings can appear in any order, so it is not a line to line comparison.
I have sample files and the expected output attached below.
Please can someone help me with .bat script? Is is there a script already built for this?
FILE1 with the below strings
Pet
brown
spray
Pet
country
jack
tip
Ball
basket
magic
whistle
cry
bag
headphone
paper
mourn
eyebrow
mental
monster
google
schedule
mountain
bottle
hint
notice
File 2 with below strings
basket
schedule
mouse
ostrich
bag
brown
basket
chair
result
fantasy
tip
hint
hurt
shirt
notice
jack
white
crack
noble
deck
cover
spray
Output file
bag
notice
spray
schedule
hint
jack
brown
tip
There will be only one word per line. Strings can appear in any order, so it is not a line to line comparison.
I have sample files and the expected output attached below.
Please can someone help me with .bat script? Is is there a script already built for this?
FILE1 with the below strings
Pet
brown
spray
Pet
country
jack
tip
Ball
basket
magic
whistle
cry
bag
headphone
paper
mourn
eyebrow
mental
monster
schedule
mountain
bottle
hint
notice
File 2 with below strings
basket
schedule
mouse
ostrich
bag
brown
basket
chair
result
fantasy
tip
hint
hurt
shirt
notice
jack
white
crack
noble
deck
cover
spray
Output file
bag
notice
spray
schedule
hint
jack
brown
tip