[英]comparing the two values line by line from two different text files
i have two text files i want to compare the data between the two text files line by line and i have to maintain the matched values in to one file and unmatched values in to another file.我有两个文本文件,我想逐行比较两个文本文件之间的数据,我必须将匹配的值保留在一个文件中,将不匹配的值保留在另一个文件中。 i am giving the examples
我在举例
a.txt
10
20
30
the values in the a.txt are appending horizontally. a.txt 中的值水平附加。
b.txt
10
30
20
the values in the b.txt are appending vertically b.txt 中的值垂直附加
can u help me to write a shell script for comparing the above two text files line by line.if the line is matched i have to send the output to the one line else it has to send the out put to the another file.你能帮我写一个shell脚本来逐行比较上述两个文本文件吗。如果该行匹配,我必须将输出发送到一行,否则它必须将输出发送到另一个文件。
i/o is 10 only.(line with possition comparission). i/o 仅为 10。(与位置比较一致)。
Maybe try:也许尝试:
paste a.txt b.txt | sed -n '/\([0-9]\+\)[[:space:]]\+\1/p' > c.txt
c.txt
will contain: c.txt
将包含:
10 10
And和
paste a.txt b.txt | sed '/\([0-9]\+\)[[:space:]]\+\1/d' > d.txt
d.txt
will contain: d.txt
将包含:
20 30
30 20
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.