If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Can you test a file for ASCII encoding?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-08, 10:35
brianr8011 brianr8011 is offline
Registered User
 
Join Date: Sep 2007
Posts: 6
Can you test a file for ASCII encoding?

Hi all.

I'm still fairly new at this (shell scripting) so bear with me....

I currently have a script that tests to see if a $1 is a file :

Code:
if [[ -f $filename ]] then
   do_stuff
else
   echo "$filename is not a regular file"
fi
My question: is there a way to test that the file $filename is in ASCII and not another encoding type? I am using Korn shell.

Thanks for any help.

EDIT: I should note that $1 is assigned to filename before this code segment.

Last edited by brianr8011; 07-16-08 at 13:44.
Reply With Quote
  #2 (permalink)  
Old 07-16-08, 12:17
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can use the "file" utility if it is installed.

$ file Configurator.hpp
Configurator.hpp: ASCII C++ program text
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On