我有两个文件Corbeau.txt和Loup.txt。我想通过shell脚本找到它们的共同用语。
我做到了。 有什么想法吗?
#!/bin/sh
corbeau_txt=$(egrep -o "\w{2,}" Corbeau.txt | sort | uniq)
loup_txt=$(egrep -o "\w{2,}" Loup.txt | sort | uniq)
communs=" "
for mot1 in $corbeau_txt
do
for mot2 in $loup_txt
do
if [ $mot = $mot2 ]
then
communs=$mot2
echo $communs
fi
done
done