0

I'm having an issue with pattern matching. I know the solution to this should be relatively simple but I'm stuck. Lets say

for something in ${OPTARG[@]} ; do
[[ ${path} =~ "J"${something} ]] 

In this case, I want OPTARG = 1

When I run this it returns all matches to 1 i.e. J112, J174 etc and I ONLY want it to return J1

Any ideas?

1 Answer 1

1

Use $ that matches the end of the string:

[[ $path =~ J$something$ ]]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.