Comparing two files
Can anyone create a script for a file comparison?
The pseudo code looks like this
- extract line 5 from file 1
- save it in another variable,
- extract line 5 from file 2,
- save it in another variable,
if variable 开发者_运维知识库1 is not equal to variable 2 (while allowing for differing characters at positions 11 and 12 from the end of line)
- then fail
- else pass
Unix shell? Pass the fileneames as arguments to the following script:
#!/bin/sh a="$(head -n 5 < $1|tail -n 1)" b="$(head -n 5 < $2|tail -n 1)" test "$a" = "$b" && (echo The same; exit 0) echo Different; exit 1
精彩评论