shell - To Compare two space delimited files -


I have two files below. I want to compare and know whether two lines are the same or not in both files < / P>

file1.txt:

  4162 8171.0 2.00 F Noel Faucet 25.630 05-05-2015 256 45.2 5.00 N Faucet 16.098 2011-11-20  

file2.txt:

  4162 8171.0 2.00 F Noall Faucet 25.630 05-05-2015 561 41.0 10.00 En Nail Number 16.098 2011-11-20  

I used the code below using the awk command.

  rownum = 1 cat file1.txt | While reading-R line || [[N $ line]]; Do not enter "line $ rownum" if "[$ $ row_same"], then "line $ rownum does not match" if the line_same = `educ '/ $ LINE / {print;}" file2.txt; if [["" $ row_same "=' ']] = "$ LINE"]], then "line $ rownum is not matched" $ ((Rownum + 1))  

expected output:

 < Code> line 2 is not matched  

actual output "

  line 1 is not matched, row 2 is not matched.  

Please help me why this is not working.

diff < / Code> It is a good to do this, however if you want to read lines from both lines also you can also No need to use awk .

  count = 0 while IFS = read -r line A & amp; IFS = read -r lineB & lt; & Amp; 3 count = 'expr $ count + 1` if ["$ lineA"! = "$ LineB"]; Then "line $ count" does not match "file 1.txt 3; Lt; File2.txt " 

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -