-1

How to pass variable as input to sed command instead of file please find the example below. I am trying to use the command but I am not able to pass the variable

test=$(I have shell script here which stores the value in test)

Now I want to read the variable and deletethe lines where I find the value 'xyz'

Command i tried

sed -i /xyz/d “$test”
Ivan
  • 6,188
  • 1
  • 16
  • 23
Vani
  • 11
  • 1
  • 2

1 Answers1

0

Process your var like this

echo "$test" | sed '/xyz/d'

Or like this

sed '/xyz/d' <<< "$test"
Ivan
  • 6,188
  • 1
  • 16
  • 23