Artificial intelligent assistant

sed: -e expression #1, char 1: unknown command: `'' I have already read a similar question, but there is no solution to my problem. I want to delete some line in some file I use sed in the script this is the code. line="this" del='echo "'/"$line"/d'"' #it's a AltGr+7 on AZERTY keyboard but for readability of the code I use ' sed -i $del /home/example/fic.txt I also try: line="this" del='echo "/"$line"/d"' sed $del /home/example/fic > /home/example/fic but I have the same error: sed: -e expression #1, char 1: unknown command: `''

Try this,


line="this"
del=`echo "/"$line"/d"`
sed $del /home/example/fic > /home/example/fic


In your code, you are single quotes while assigning value to variable `del`. which will consider as a static string rather than executing it. We can use backticks or `$()` to execute it.

better way,


line="this"
sed -i "/$line/d" /home/example/fic


* `-i` edit in line.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3caebd9471b64cf149f608a0f8b60460