A script that produces as output not the identical lines but the different

I have the 2 files file1 and file2
the 2 files have the following records per line

A big number of records are identical in file 1 and file2
I have truied to concatenate
cat file1 >> file2
and sort file2
and make
uniq -u file2
in order to receive only the different lines and not the common but it doesn't work.
What command can I use in order to do it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cat file2 | sort -u > file2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vage78Author Commented:
Hi yuzh
It doesn't works. I only want the lines that exist only ONE time in my file. I don't want to receive the adiacent lines that are identical
can you use diff?

> diff file1 file2
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.


sort -u (as yuzh said)
diff (as durindil said)
also try 'comm' - it may happen that's you're looking for (read man carefully - or you may not achieve a good result!).

vage78Author Commented:
My problem is that after cutting off the spaces at my file
when I'm making
uniq -u file2
are not coming out the unique lines contrarily come all.
What can  do?
I think you use
command  comm.
ust out the details for this command using
man comm

I think you use
command  comm -3 file1 file2.
find more details for this command using
man comm

vage78Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.