5
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
ASCII? In the days of internet and Unicode? You must be joking. – user1686 – 2010-10-26T22:23:15.317
You do realize that
file
is a heuristic guess and not a guarantee, right?yes | head -c $((2**20)) > blah; dd if=/dev/urandom bs=1 count=1024 >> blah; file blah
saysblah: ASCII text
even though it's not. – ephemient – 2010-10-27T19:07:24.970yes I am understand but what I need to do if I want to make selection of files type , what the best thing to do? , any idea? – jennifer – 2010-10-27T20:21:20.020