Skip to main content
edited body; edited title
Source Link
Mat
  • 54.9k
  • 11
  • 164
  • 143

using Using regex inside if clause -in bash

lookLook at this if block:

#!/bin/bash

str="m.m"
if [[ "${str}" =~ "m\.m" ]]; then
    echo "matched"
else
    echo "not matched"
    exit 1
fi

exit 0

This should print "matched", but it doesn't. where IWhere am I going wrong?

using regex inside if clause - bash

look at this if block:

#!/bin/bash

str="m.m"
if [[ "${str}" =~ "m\.m" ]]; then
    echo "matched"
else
    echo "not matched"
    exit 1
fi

exit 0

This should print "matched", but it doesn't. where I am going wrong?

Using regex inside if clause in bash

Look at this if block:

#!/bin/bash

str="m.m"
if [[ "${str}" =~ "m\.m" ]]; then
    echo "matched"
else
    echo "not matched"
    exit 1
fi

exit 0

This should print "matched", but it doesn't. Where am I going wrong?

Source Link
Majid Azimi
  • 3.2k
  • 7
  • 33
  • 37

using regex inside if clause - bash

look at this if block:

#!/bin/bash

str="m.m"
if [[ "${str}" =~ "m\.m" ]]; then
    echo "matched"
else
    echo "not matched"
    exit 1
fi

exit 0

This should print "matched", but it doesn't. where I am going wrong?