With the file command I need to verify many files if they ASCII or other format
Sometimes I get from file command:
file1: ASCII English text
And sometimes I get different answer from file command
file2: Non-ISO extended-ASCII English text, with very long lines
I am really not sure if there are other answers with different syntax
My question is:
I write the follwing ksh syntax to verify if file is a ASCII but I not sure if the
following syntax is the optimal syntax in order to verify ASCII format?
[[ ` file $some_file | grep –c ASCII ` = 1 ]] && print "you have ascii file for sure"
If someone have other suggestion to verify ASCII format for sure!, I will very glad to see that
fileis a heuristic guess and not a guarantee, right?yes | head -c $((2**20)) > blah; dd if=/dev/urandom bs=1 count=1024 >> blah; file blahsaysblah: ASCII texteven though it's not. – ephemient Oct 27 '10 at 19:07