Could anyone tell me why this is not working?
Temp=$(sed -n '/"${Arr[$index]}"/,/"${Arr[$((index+1))]}"/p' $Text);
It still does not work. I tried to do this:
index=0
while [ "$index" -lt "$((Arr_LEN-1))" ]; do
Temp=$(sed -n "/${Arr[$index]}/,/${Arr[$((index+1))]}/p" $Text);
let "index++"
done
Because the sed
script is in single quotes, which prevents all expansion:
Enclosing characters in single quotes preserves the literal value of each character within the quotes.
Changing single quotes to double quotes should help though:
Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \, and, when history expansion is enabled, !. The characters $ and ` retain their special meaning within double quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With