grep command

Dear friends,

I am new to Unix and want to explore more on Unix commands. Please check the below code and advice.

  1. I want to pass each line to while loop from a input file.
    2.Want to grep first line with specific pattern, if it is success than do some action, if not than do else action .

  2. Now read the 2 line of input and follow the same above steps.

  3. Now problem here i am facing if how to pass the first line to grep, as much as i am aware grep req. file name to search in it.

Here is my code:

# set -x
while read line
do
x=$line
grep -i .par$ $x
if [ "$?" = 0 ]; then
cd ../par
echo "Do the action"
else
cd../sql
echo "Do the action with else part"
fi
done <inp.txt

You don't have to assign $line to $x. To grep the variable use:

echo "$line" | grep -i .par$

Thanks a lot it works fine ,$100 party to bartus11