##!/bin/bash
echo "pleases enter a.txt file(enter q to exit)"
read -dq A

echo " "

echo "pleases enter b.txt file(enter q to exit)"
read -dq B

echo " "

cat > /root/a.txt <<Eof
$A
Eof
cat > /root/b.txt <<Eof
$B
Eof
C=`cat /root/a.txt | grep -f /root/b.txt`
D=`cat /root/a.txt | grep -f /root/b.txt | egrep -v "^$" | wc -l`
if [ $D -eq 0 ];then
     echo "没有相同字符,请重新输入,标识:N"
fi
if [ $D -ge 1  ];then
echo "恭喜!有相同字符,标识:Y"
cat > /root/c.txt << Eof
$C
Eof
echo "the c.txt file is:"
echo $C
fi