compare two files not line by line

September 21, 2011 at 18:51:45
Specs: Windows XP
hi everyone, I want to ask something for the following file:

file1:
909
919
929
932

file2:
909 9
929 9

output:
919
939

How can I do it in shell scripting. It cant be in diff, because diff is in line by line method. please assist, thanks for advance..


See More: compare two files not line by line

Report •

#1
September 21, 2011 at 20:31:52
Here are two links that discuss reading a file line-by-line:

http://www.computing.net/answers/un...
http://www.computing.net/answers/un...


Report •

#2
September 22, 2011 at 16:09:19
thanks, i need character by character.. not line by line.. and the length of each line.. so other character cant be read..

Report •

#3
September 22, 2011 at 20:20:18
Do you know that you can parse the 2 fields this way:

while read f1 f2
do
   echo $f1  # line 1, col 1 equals 909
   echo $f2  # line 1, col 2 equals 9
done < file2

Anyway, here is an example that cycles thru a file, finds each line's length and looks at certain characters using the cut command:

http://www.computing.net/answers/un...

Maybe you can modify it to fit your needs.


Report •
Related Solutions


Ask Question