To check the content of one file in another

Hi ,

I have a file called "X" . the content of X are
X
--
abc
def

and i have a file called "Y" , the content of Y are
Y
--
erty
sdss
s
abc
sfs
def

I need to check if the content of file X is contained in Y.Only unix

Can u plz help me.

Thanks

And what do you want to have in the output?

If the content of X is contained in "Y"

I need to print "Yes" else "No"

Try grep with the -f and if necessary the -v option. Read the man page of grep.

Regards

for i in `cat X`; do grep $i Y; done

Will print all records from file X that exist in Y.

Why exactly do you need a 'cat' there?

Please use the below script:-
copy the script and run them in the unix BASH environment.

count=`wc -l X|cut -d" " -f1`
echo $count
counter=0
for i in `cat X`
do
for j in `cat Y`
do
echo $j | grep $i
if [ $? -eq 0 ]
then
counter=`expr $counter + 1`
fi
done
done
if [ $counter -eq $count ]
then
echo "Both are Same"
else
echo "Both are different"
fi

Guys....

I dont wanna print all that are there in X containing in Y.

All i need to print is "Yes" if X is contained in Y and "No" if not , because in my real scenario the content of X and Y is very large.

Thanks