# more infile
adfad
aadfsdfsa
adfadsf
<name>TypeOptions</name>
adfdasf
adfad
adfad
# more lineadd.sh
#!/bin/sh
echo "Enter the pattern to search ?"
read pattern
echo "Enter the line to add ?"
read line_add
while read line
do
ch1=`echo $line|grep $pattern|wc -l`
if [ $ch1 -ne 1 ]
then
echo $line >> outfile
else
echo $line >> outfile
echo $line_add >> outfile
fi
done < infile
# ./lineadd.sh
Enter the pattern to search ?
name
Enter the line to add ?
found the pattern "name"
# more outfile
adfad
aadfsdfsa
adfadsf
<name>TypeOptions</name>
found the pattern "name"
adfdasf
adfad
adfad