LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using diff and erasing the lines that match (https://www.linuxquestions.org/questions/linux-newbie-8/using-diff-and-erasing-the-lines-that-match-485199/)

ElectroLinux 09-20-2006 02:21 AM

Using diff and erasing the lines that match
 
How do I diff two files and erase the lines that are the same without having to go into an editor?

So if i have

List A
1
2
3
4
5
6

List B
2
4
6

If i diff these two files, i'd want to be able to have
List A -B = C

List C
1
3
5

Zmyrgel 09-20-2006 03:20 AM

Pipe is your friend. Also check sed and awk as they would be helpfull.

I think something like "diff list_A list_B > list_C" would work.

ElectroLinux 09-20-2006 03:30 AM

No, that would just get me output of the diff...i want to actually get rid of any lines that match in List B.

druuna 09-20-2006 03:31 AM

Hi,

Using one command:

comm -3 list_A list_B

man comm for details.

Hope this helps.

ElectroLinux 09-20-2006 03:34 AM

That is exactly what I was looking for. THANKS!


All times are GMT -5. The time now is 09:24 AM.