compare files

Hi,

I have 2 files (1stfile.log, 2ndfile.log)

Contents of the files:

1stfile.log:
GERMANY01
UK11
US11
ITALY11

2ndfile.log:
Germany01
US11
UK11
ITALY22
BELGIUM11
CHINA11
JAPAN11

I would like to have a script that return 0 if all contents in 1stfile.log are also found in 2ndfile.log, and their case sensitive, if case doesn't match their counsider not found. return 1 if any of the contents in 1stfile.log not found in 2ndfile.log.

Any help would highly appreciated.
thanks

while read line; do grep -w $line 2ndfile.log || exit 1; done < 1stfile.log

use code tag [code] The UNIX and Linux Forums - BB Code List

Any other way to do it, let say if we use if then else?
thanks

#!/bin/bash
f1c=$(awk 'END {print NR}' file1)
cal() {
for((i=1;i<=$f1c;i++)) ; do
f1=$(awk 'NR=='$i'' $1)
while read -r f2 ; do
if [ "$f1" != "$f2" ] ; then
is=notok;else is=ok;break;fi
done<$2
if [ "$is" != "ok" ] ; then
return 1;fi;done
}
cal "$1" "$2"
echo "Exit status code is $?"
# ./s file1 file2
Exit status code is 1

regards
ygemici

in awk..

$ awk '{print "grep -w "$0" file2 || exit 1"}' file1 | sh ; echo $?