LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-29-2013, 02:05 PM   #1
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 22

Rep: Reputation: Disabled
file command sees regular ASCII text file as ASCII Java program text


I need some assistance. I have regular ASCII text documents. If any of those documents have the word "import" in it, the file command sees it as ASCII Java program text. If these same files do not have that word in it, they are seen as ASCII text. This causes a problem with what we are doing. The text documents recognized as ASCII Java program get blocked. Does anyone know if there is some kind of linux update or bug or something??? Point me on where or how to search Google for something for help?
 
Old 08-29-2013, 05:44 PM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,263

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
It is called "magic". You can instruct "file" command to ommit some tests. "file" command do the best to guess file type, for example looking inside file for searching some pattern which could reveal its type. If you do not want this behavior you can exclude some tests by adding "-e" option, for example
Code:
file -e tokens not_java_file_with_import_inside.txt

Last edited by eSelix; 08-30-2013 at 09:36 AM. Reason: Correcting "-e token" as noted by druuna
 
Old 08-30-2013, 08:21 AM   #3
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
-e is not a file command option
When I run it with the -e option it tells me file: invalid option -e
 
Old 08-30-2013, 08:54 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394
Quote:
Originally Posted by bbraml View Post
-e is not a file command option
When I run it with the -e option it tells me file: invalid option -e
Is this on Linux or some Unix variant?
Code:
$ file --version
file-5.04
magic file from /etc/magic:/usr/share/misc/magic
One other thing; It should be tokens, not token:
Code:
$ file -e tokens not_java_file_with_import_inside.txt
tokens not_java_file_with_import_inside.txt: ASCII text

$ file not_java_file_with_import_inside.txt
tokens not_java_file_with_import_inside.txt: ASCII Java program text
 
Old 08-30-2013, 09:08 AM   #5
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
This is on RHEL 5.7 linux

Code:
$ file --version
file-5.04
magic file from /etc/magic:/usr/share/misc/magic
 
Old 08-30-2013, 09:35 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394Reputation: 2394
Quote:
Originally Posted by bbraml View Post
This is on RHEL 5.7 linux

Code:
$ file --version
file-5.04
magic file from /etc/magic:/usr/share/misc/magic
Are you sure about that? RHEL 5.7 and file version 5.04?

This is on my RHEL 5.7 box:
Code:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.7 (Tikanga)

$ file --version
file-4.17
magic file from /usr/share/file/magic
Version 4 does not have an -e switch or something similar.
 
Old 08-30-2013, 09:52 AM   #7
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
Sorry,
one server is 5.1 and another is 5.6
both are running file version 4.17
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to convert encoding between ASCII text and ASCII English text astanton Linux - General 2 08-03-2011 04:55 PM
[SOLVED] Prepend to ASCII text file in C MS3FGX Programming 4 06-22-2010 11:09 PM
How to save text file with ASCII code?? Nejad General 7 01-04-2009 03:17 AM
Convert ASCII text to an audio file ed_homeLinux Linux - Software 1 07-22-2005 01:30 PM
Displaying a text file in ascii?? bauld Linux - General 4 11-21-2001 08:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration