Dear friends,
I am new to Unix and want to explore more on Unix commands. Please check the below code and advice.
-
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 . -
Now read the 2 line of input and follow the same above steps.
-
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