Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-14-2004, 08:51 AM   #1
Registered: Jun 2004
Posts: 36

Rep: Reputation: 15
Finding lines in file1,but not in file 2

I had used a command for this once, but forgot.

I have two files test1 and test2

cat test1:-
ingres!ingresr30!generic!back!awsf!hdr wsfinit.h 2
ingres!ingresr30!generic!back!awsf!hdr wsfvar.h 6
ingres!ingresr30!generic!back!awsf!hdr sfvar.h 6

cat test2
ingres!ingresr30!generic!back!awsf!hdr sfvar.h: file not had on subutest
ingres!ingresr30!generic!back!awsf!hdr wsfvar.h: file not had on subutest
ingres!ingresr30!generic!back!awsf!hdr wsfinit.h 2

I want to find lines that are in test1, but not in test2.
So the o/p should be :-
ingres!ingresr30!generic!back!awsf!hdr wsfvar.h 6
ingres!ingresr30!generic!back!awsf!hdr sfvar.h 6

What should I do?

Thanks in advance.

Old 12-14-2004, 10:44 AM   #2
LQ Newbie
Registered: Jan 2004
Location: Danville, VA
Distribution: LFS
Posts: 1

Rep: Reputation: 0
grep -vhFxf test2 test1
Old 12-14-2004, 10:56 AM   #3
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,421

Rep: Reputation: 200Reputation: 200Reputation: 200
or try
man comm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I sort the lines in a file? windhair Linux - Software 2 11-17-2005 09:37 AM
erase all the lines of a file Prasun1 Linux - General 9 11-06-2005 11:53 AM
How to remove lines from a file doza Linux - General 2 04-27-2005 12:59 PM
Removing lines from file Aylar Programming 2 04-22-2004 07:34 AM
delete some lines from a file freelinuxcpp Linux - Software 4 01-17-2004 11:28 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration