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 - 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, 01:05 PM   #1
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 24

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, 04:44 PM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
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 08:36 AM. Reason: Correcting "-e token" as noted by druuna
 
Old 08-30-2013, 07:21 AM   #3
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 24

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, 07:54 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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, 08:08 AM   #5
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 24

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, 08:35 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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, 08:52 AM   #7
bbraml
LQ Newbie
 
Registered: Sep 2011
Posts: 24

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


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

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

All times are GMT -5. The time now is 04:44 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