Question: I have a file, I want to determine if it contains only English ASCII characters.

I thought this is a very common question, but when I googled it, there is no direct answer or related. 

According to some other questions, this is what I got so far, but this doesn't work. No matter ASCII or Non-ASCII chars, it will always determine as non-ascii.

```
if (LC_ALL=C; [[ $TEXT = *[[:ascii:]]* ]]) then
  echo "Contain Non-ASCII"
fi

```

BTW, This is a shell script.

Answer: 
The `file` command can tell you the type of a file (ASCII, unicode, binary, etc.). 

```
$ file my_file.txt
my_file.txt: ASCII text

```

So you can just check to see that the output contains the word "ASCII" and this should work:

```
if [[ file my_file.txt | grep -i ascii ]] ...

```
```
TEXT=SOMETEXTHERE

RESULT=$(echo $TEXT | LC_COLLATE=C grep -r '[^ -~]')
if [ -z "$RESULT" ]; then
    echo "ALL ASCII"
else
    echo "Contain Non-ASCII"
fi

```