Search Results

Search found 1 results on 1 pages for 'preservedmoose'.

Page 1/1 | 1 

  • Why does this Bash regex match return an Exit Status of "2"?

    - by PreservedMoose
    I'm writing a Bash script that needs to scan for the existence of non-ASCII characters in filenames. I'm using the POSIX bracket regex syntax to match the non-ASCII characters, but for some reason, when I test for the match in an if/then statement, the test always returns an Exit Status of 2, and never matches my test string. Here's the code in question: FILEREQ_SOURCEFILE="Filename–WithNonAScII-Charàcters-05sec_23.98.mov" REGEX_MATCH_NONASCII="[^[:ascii:]]" if [[ $FILEREQ_SOURCEFILE =~ $REGEX_MATCH_NONASCII ]]; then echo "Exit Status: $?" echo "Matched!" else echo "Exit Status: $?" echo "No Match" fi This code always returns: Exit Status: 2 No Match I've read and re-read the bash-hackers.org explanation of how regex matching works, as well as this previous question on SO regarding matching non-ASCII characters, but for the life of me, I can't get this to work. What am I missing here?

    Read the article

1