yes, you can try to print the result of both:
Code:
sed "${Line}!d" $rutaFich/titles
sed "/'"${i}"'/I!d" $rutaFich/titles
to see what are they doing exactly. I would say the two sed commands will delete everything, most probably because of the pattern or the second sed is not exactly what you want (see post #4).
From the other hand running the first sed in a loop is just waste of time and cpu, but probably it is not that important in your case.
For readability probably I would use awk
Code:
while read -r Line; do
echo "Line $Line"
for i in "${patrones[@]}"
do
found=$(awk -v Line=$Line -v pattern="$i" ' NR != Line { next } $0~pattern ' $rutaFich/titles)
if [[ -n $found ]]; then
echo "find it pattern $i en la linea $Line"
exit 0
else
echo "No encontrado el patron $i en linea $Line"
fi
done
done < $rutaFich/differences
Not tested, just an idea. It will still read the file $rutaFich/titles in loop, so still better:
Code:
while read -r Line; do
echo "Line $Line"
data="$(sed -n ${Line}p $rutaFich/titles)"
for i in "${patrones[@]}"
do
if [[ $data =~ $i ]]; then
echo "find it pattern $i en la linea $Line"
exit 0
else
echo "No encontrado el patron $i en linea $Line"
fi
done
done < $rutaFich/differences
or something similar