LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-24-2003, 12:02 PM   #1
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68

Rep: Reputation: 15
Determining if a file is binary or text


Hi all,

In a shell script I need to determine whether a file is a binary or a pure text file. The test has to be 100% reliable.

Any ideas?

cheers!
Cyth
 
Old 02-24-2003, 12:51 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
First of all, unlike DOS/Windoze, Linux and other Unixes
don't distinguish between binary and text in (file) streams.

That said, have a look at
Code:
man file
and understand that the 100% reliability
is your own duty by modifying/extending
Code:
man magic
Enjoy!


Cheers,
Tink
 
Old 02-27-2003, 08:31 AM   #3
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68

Original Poster
Rep: Reputation: 15
Yes I've had a look at the file utility but I find it hard getting exact output even if I tell it to output in standard RFC format(forgot it's name, not on a linux computer while writing this). It's not consistent in it's output..


cheers,
Frans
 
Old 02-27-2003, 12:36 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
The alternative would be for you to come up
with a tool yourself, one that maintains a database
and prompts you if a new format is encountered...

Pretty much an "intelligent agent" tool, shouldn't
be too hard ;)

Cheers,
Tink
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
timezone binary to text file jude1980 Linux - Software 0 11-23-2005 06:07 AM
How to convert binary text file from Windows marie@dk Linux - Software 2 10-12-2005 03:17 AM
Automatically tell text file from binary file? Hosiah Linux - Software 3 05-31-2005 05:22 AM
convert text file to binary excel file ust Linux - General 2 11-23-2004 02:33 AM
determining a binary file debdas Programming 3 05-05-2003 06:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration