1

I have a file named abc.txt with below content.

838929po/83738 ijwiwj
dkljqdk
dmwqdwq

then I assign the first pattern to a variable.

var=`cat abc.txt | head -n1 | cut -f1 -d' '`

then I use $var to delete the line in sed as below.

sed ';'$var';d' abc.txt > abc1.txt

But I am getting below error.

sed: -e expression #1, char 9: extra characters after command

It is because of "/" character in $var.

Can anybody help how can I delete the line. I have to use $var at any cost.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274

0 Answers0