Sample Header Ad - 728x90

Bash: Regex for comparing file path

2 votes
2 answers
2525 views
I want to check if an input string matches whitelisted file paths, then only I want to perform some operation. I am doing something like this path1="mydir/**" path2="mydir/testing" [ [ "$path2" =~ "$path1" ] ] && echo "Matches" Where, if paths are like mydir/test/dir mydir/othertest/dir These should pass. Above check is giving me an error assets/bin/copymain: line 8: [: too many arguments
Asked by Ankit (121 rep)
Jun 1, 2019, 04:26 PM
Last activity: Dec 5, 2023, 05:01 PM