comparing 2 files and creating third file with uncommon content

I want to compare 2 files and create third file with uncommon content.
e.g.
file1
ajay suhas tom nisha vijay mahish
file2
ajay suhas tom nisha

expected output file content
vijay mahish

Is it possible in single command ?

Thanks,
Ajay

Hi ajaypatil_am,

How many lines in files? Same number of lines for both input files?

Regards,
Birei

there are thousands of lines.No number of line can be different in both the files

Try:

$ cat file1
ajay suhas tom nisha vijay mahish
ajay suhas tom nisha vijay mahish
ajay suhas tom nisha vijay mahish
ajay suhas tom nisha vijay mahish
$ cat file2
ajay suhas tom nisha
ajay suhas tom
tom
tom nisha
$ cat script.pl
use warnings;
no strict qw(refs);

die qq[Usage: perl $0 <file1> <file2>\n] unless @ARGV == 2;

open my $fh1, qq[<], shift or die qq[Cannot open input file: $!\n];
open my $fh2, qq[<], shift or die qq[Cannot open input file: $!\n];

while ( my $l1 = <$fh1>, my $l2 = <$fh2> ) {
        chomp( $l1, $l2 );
        my %h1 = map { $_ => 1 } split /\s+/, $l1;
        delete @h1{ split( /\s+/, $l2 ) };
        printf qq[%s\n], join qq[ ], keys %h1;
}
$ perl script.pl file1 file2
vijay mahish
vijay mahish nisha
suhas vijay mahish nisha ajay
suhas vijay mahish ajay

Regards,
Birei

sorry if i was not clear ...the both the files will contain only one 'ajay' only one 'suhas' but there can be thousand of such names...
all i want is the thrid file with names which are there in file 2 but not in file1..

I don't understand what do you expect.

Do you want to compare both files line by line? Post a bigger example.

Regards,
Birei

I want the uncommon contents from 2 files
e.g.
file1
a b c d e
file2
a d
expected output
b c e
I would prefer a shell script than perl.In both the files contents will be unique meaning a b c d e a b c this will not be the case.In short no name in the files will repeat.

Thanks,
ajay