I did a little code that works with sed in a script and I need to replace the line 5 in file.txt with a random generated characters as shown bellow but I will write in the below code just one set of characters to simplify it.
var='6C|&}|X_5gaJ|^s U/>+c,G>$Xe]t^</$H-$K;1?Im~bk]_z3gJo@1,y`eVb{kt?' #those characters are always changing in my code with another command
sed -i "5s|.*|$var|" file.txt
I tried to work with |
instead of /
but even that doesn't work because as you can see in the set of the characters in var
it contains |
and an error occurs.
So is there any way to solve this issue without modifying the characters in the value of var? because as I said above, it generated every time.