This will yield 1 for identical lines, 2 for different.
0
potong
On
This might work for you:
sed -n '$!h;${G;/\(.*\)\n\1$/{s/.*/1/p;q};s/.*/0/p}' filename.txt
0
jman
On
How about this:
lc=`wc -l filename.txt | cut -d " " -f1`
if [ $lc -ge 2 ]
then
ulc=`tail -n 2 filename.txt | uniq | wc -l`
if [ $ulc -eq 1 ]
then
echo "Last two lines are identical"
fi
fi
This will yield
1
for identical lines,2
for different.