English 中文(简体)
在小标题中,我想把昨天的卷宗与今天的档案相比较,只是从今天的产量变化,忽视了一些领域。
原标题:In linux I want to compare yesterday s file to today s file getting only changes from today as the output, ignoring some fields

我有2个管道有限档案。 昨天和今天。 txt

昨天txt:

1234|12|Bill|Blatt|programmer
3243|34|Bill|Blatt|dentist
98734|25|Jack|Blatt|programmer
748567|31|Mark|Spark|magician

今天,txt

123|12|Bill|Blatt|programmer
3243|4|Bill|Blatt|dentist
934|25|Jack|Blatt|prograbber
30495|89|Dave|Scratt|slobber

I would like to compare the 2 files while ignoring the first 2 fields and output any lines unique to the second file (今天,txt), but I want the full lines even though the comparison is omitting the first 2 fields. So in the case above the output would be:

new_今天,txt

934|25|Jack|Blatt|prograbber
30495|89|Dave|Scratt|slobber

我试图利用这一点:

sort <(cut -d"|" -f3- yesterday.txt) <(cut -d"|" -f3- yesterday.txt) <(cut -d"|" -f3- 今天,txt) | uniq -u

这几乎是行之有效的,但它给我留下了我削减的2个领域。 我不知道如何做到这一点。 任何帮助都会受到高度赞赏。

问题回答

Reusing most of your code:

sort <(cut -d"|" -f3- yesterday.txt) 
     <(cut -d"|" -f3- today.txt) |
     uniq -u |
     xargs -I% grep  %  today.txt || true

Output

30495|89|Dave|Scratt|slobber
934|25|Jack|Blatt|prograbber

。 不能轻易地忽视管道有限的田地,否则会理想。 借助空间有限投入,你才能做到:

sort -k3 yesterday.txt yesterday.txt today.txt |
uniq -f2 -u

如果我们在运行<条码>uniq<<><>条码>之前抽取空间和管道,然后在其后回击:

sort -t |  -k3 yesterday.txt yesterday.txt today.txt |
tr   |   |   |
uniq -f2 -u |
tr   |   |  




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签