My file contains the below entries:
cat /tmp/test.yaml
---
10.8.8.26:
/tmp/win5835113081224811756.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
/tmp/win03745991442278706.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
10.9.9.26:
/tmp/conf/extra/httpd-ssl.conf:
hash: 1746f03d57491b27158b0d3a48fca8b5fa85c0c2
/tmp/conf/httpd.conf:
hash: 1746f03d57491b27158b0d3a48fca8b5fa85c0c2
and so on...
I wish to delete a particular IP say 10.8.8.26 and it's file details from test.yaml
They below regex helps grab the details i wish to delete from the file and therefore i store it in a variable called check:
export check=`grep -Pzo '[^#](^10.8.8.26:)(.|\n)*^(?!( |\n))' /tmp/test.yaml`
echo $check
10.8.8.26: /tmp/win5835113081224811756.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb /tmp/win03745991442278706.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
I then wanted to use the variable check to remove the grabbed entries from the file.
I tried the below commands but they do not help.
grep -v "$check" /tmp/test.yaml
And
sed "/${check}/d" /tmp/test.yaml sed: -e expression #1, char 1:
unterminated address regex
Can you please suggest how can i fulfill my requirement?