Reputation: 1
I have this if else command that always result in "no match" although I am expecting it to say "match"
$ skopeo inspect docker://abc:xyz 2>&1
time="2023-03-03T04:33:12Z" level=fatal msg="Error parsing image name \"docker://abc:xyz\": reading manifest xyz in docker-release-abc: manifest unknown: manifest unknown"
$ if skopeo inspect docker://abc:xyz 2>&1 | grep -q "manifest unknown"; then echo "match" ; else echo "no match"; fi
no match
I've tried many things including diverting the stderr to stdout using 2>&1, also tried using >/dev/null but all in vain
Upvotes: 0
Views: 157
Reputation: 1707
Using the input you provided, the problem cannot be reproduced with a test script.
Test script:
#!/bin/bash
testval='time="2023-03-03T04:33:12Z" level=fatal msg="Error parsing image name \"docker://abc:xyz\": reading manifest xyz in docker-release-abc: manifest unknown: manifest unknown"'
if echo "${testval}" 2>&1 | grep -q "manifest unknown"
then
echo "match"
else
echo "no match"
fi
Upvotes: 0