#!/bin/bash
fname=$2
rname=$1
echo \"$(<$fname)\" | while read line ; do
result=`echo \"$(<$rname)\" | grep \"$line\"; echo $?`
if [ $result != 0 ]
the
If I understand your need correctly, you want a file newaks which contains the lines in $fname which are also in $rname.
If this is what you want, using sed is overkill. Use fgrep:
fgrep -x -f $fname $rname > newkas
Also, there are problems with your script:
grep in result, which means it will never be exactly 0; what you want is executing the command and simply check for $?echoes are convoluted, just do grep whatever thefilename, or while...done ; $rname, which may yield to unexpected results.And others.