LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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
 
Thread Tools
Old 02-24-2003, 01:02 PM   #1
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68
Thanked: 0
Determining if a file is binary or text


[Log in to get rid of this advertisement]
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
Cyth is offline     Reply With Quote
Old 02-24-2003, 01:51 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :}
Posts: 18,846
Blog Entries: 1
Thanked: 160
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
Tinkster is offline     Reply With Quote
Old 02-27-2003, 09:31 AM   #3
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68
Thanked: 0

Original Poster
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
Cyth is offline     Reply With Quote
Old 02-27-2003, 01:36 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :}
Posts: 18,846
Blog Entries: 1
Thanked: 160
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
Tinkster is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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


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


All times are GMT -5. The time now is 12:05 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration