I have the following line to execute in a script and that delete two lines above it. But now my $TEST variable contain values like '/DATA/test10' and my variable ID contain '10'. How can i use this with sed?sed -i :a;N;s/\n/&/2;Ta;/path = $TEST\/$ID/s/.*//;P;D /collection.txt
how to use sed when a variable contain '/' in it?
bash;environment variables;sed
If you simply want to treat a string as a literal in sed there's already an answer for that:escaped_testx=$(sed -e 's/[\/&]/\\&/g' <<< $TEST; echo x)escaped_test=${escaped_testx%x}The extra x is to be able to handle trailing newlines, which would otherwise be removed by the command substitution.