Unix Technical Forum

Identify UNIX/DOS file

This is a discussion on Identify UNIX/DOS file within the comp.unix.solaris forums, part of the Solaris Operating System category; --> I have Unix and DOS files in a directory (unix server, Solaries). How can I identify if the file ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > comp.unix.solaris

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 02:23 PM
shulamitm
 
Posts: n/a
Default Identify UNIX/DOS file

I have Unix and DOS files in a directory (unix server, Solaries).
How can I identify if the file type is UNIX or DOS?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 02:23 PM
Oleksii Dzhulai
 
Posts: n/a
Default Re: Identify UNIX/DOS file

On Feb 24, 12:38 pm, shulamitm <shulami...@bezeq.com> wrote:
> I have Unix and DOS files in a directory (unix server, Solaries).
> How can I identify if the file type is UNIX or DOS?


There are no such file types like Unix and DOS.
It depends on what file system you are using as a storage for these
files.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 01:37 AM
Michael Vilain
 
Posts: n/a
Default Re: Identify UNIX/DOS file

In article
<579caf08-edb8-4497-9a4e-ecd02cabba59@o10g2000hsf.googlegroups.com>,
Oleksii Dzhulai <nixlike@unixinmind.com> wrote:

> On Feb 24, 12:38 pm, shulamitm <shulami...@bezeq.com> wrote:
> > I have Unix and DOS files in a directory (unix server, Solaries).
> > How can I identify if the file type is UNIX or DOS?

>
> There are no such file types like Unix and DOS.
> It depends on what file system you are using as a storage for these
> files.


If they're text files, the closest I can think of is that the "end of
line" termination is different on DOS (CR+LF) than UNIX (LF). The UNIX
file command will tell you what it thinks the file is based on it's
content.

--
DeeDee, don't press that button! DeeDee! NO! Dee...



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 01:37 AM
Richard B. Gilbert
 
Posts: n/a
Default Re: Identify UNIX/DOS file

shulamitm wrote:
> I have Unix and DOS files in a directory (unix server, Solaries).
> How can I identify if the file type is UNIX or DOS?
>
>


There is no really good way that I can think of. If a file contains
carriage returns, it's probably a Windows text file. Unfortunately
there is no guaranty that a binary file will not contain one or more
bytes that have the bit pattern of a carriage return.

The best solution that I can think of is to NOT mix Unix and DOS files
in the same directory!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-26-2008, 03:30 PM
=?ISO-8859-1?Q?Argo_S=F5=F5ru?=
 
Posts: n/a
Default Re: Identify UNIX/DOS file

shulamitm wrote:
> I have Unix and DOS files in a directory (unix server, Solaries).
> How can I identify if the file type is UNIX or DOS?
>
>

To determine file type you can use "file" command. You can update your
self or use alternative magic file (/etc/magic) also.
Find all file types in current directory:
#for i in *; do file "$i" ; done

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 03:30 PM
Dave Uhring
 
Posts: n/a
Default Re: Identify UNIX/DOS file

On Tue, 26 Feb 2008 14:16:20 +0200, Argo Sõõru wrote:

> shulamitm wrote:
>> I have Unix and DOS files in a directory (unix server, Solaries).
>> How can I identify if the file type is UNIX or DOS?
>>
>>

> To determine file type you can use "file" command.


Really?

[duhring@einstein ~]$ file test_file
test_file: ascii text
[duhring@einstein ~]$ unix2dos test_file test_file.txt
[duhring@einstein ~]$ file test_file.txt
test_file.txt: ascii text

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-26-2008, 03:30 PM
=?ISO-8859-1?Q?Argo_S=F5=F5ru?=
 
Posts: n/a
Default Re: Identify UNIX/DOS file

Dave Uhring wrote:
> On Tue, 26 Feb 2008 14:16:20 +0200, Argo Sõõru wrote:
>
>> shulamitm wrote:
>>> I have Unix and DOS files in a directory (unix server, Solaries).
>>> How can I identify if the file type is UNIX or DOS?
>>>
>>>

>> To determine file type you can use "file" command.

>
> Really?

I didn't say that help identify UNIX or DOS text files, as Shulamitm
didn't say that files are text files.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-26-2008, 03:30 PM
Marc
 
Posts: n/a
Default Re: Identify UNIX/DOS file

Dave Uhring wrote:

>>> I have Unix and DOS files in a directory (unix server, Solaries).
>>> How can I identify if the file type is UNIX or DOS?

>> To determine file type you can use "file" command.

> Really?
>
> [duhring@einstein ~]$ file test_file
> test_file: ascii text
> [duhring@einstein ~]$ unix2dos test_file test_file.txt
> [duhring@einstein ~]$ file test_file.txt
> test_file.txt: ascii text


Trying the same on a recent linux distro:
$ echo hello > a
$ file a
a: ASCII text
$ unix2dos a
$ file a
a: ASCII text, with CRLF line terminators

Now that's a bit more helpful. Usually I open text files with vim, and
when it is a dos text file it says so at the bottom.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-26-2008, 03:30 PM
=?ISO-8859-1?Q?Argo_S=F5=F5ru?=
 
Posts: n/a
Default Re: Identify UNIX/DOS file

Dave Uhring wrote:
> On Tue, 26 Feb 2008 14:16:20 +0200, Argo Sõõru wrote:
>
>> shulamitm wrote:
>>> I have Unix and DOS files in a directory (unix server, Solaries).
>>> How can I identify if the file type is UNIX or DOS?
>>>
>>>

>> To determine file type you can use "file" command.

>
> Really?

But it also solaris find/magic issue. I test file command under opensuse
and i get:
argo@ceres:~/Documents> file test_file_unix.txt
test_file_unix.txt: ASCII text
argo@ceres:~/Documents> file test_file_dos.txt
test_file_dos.txt: ASCII text, with CRLF line terminators

....so I coping linux magic file into my home dir and using it:
#file -m ./magic test_file_unix.txt
test_file_unix.txt: ASCII text
and
#file -m ./magic test_file_dos.txt
test_file_dos.txt: ASCII text, with CRLF line terminators
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-26-2008, 03:30 PM
Marc
 
Posts: n/a
Default Re: Identify UNIX/DOS file

Huge wrote:

>>>>> How can I identify if the file type is UNIX or DOS?
>>>> To determine file type you can use "file" command.
>>> Really?

[does not work]
>> Trying the same on a recent linux distro:

[works]

> Cast your eyes up to the top of the screen, where I imagine the name of this
> newsgroup is displayed. Where does it say "Linux"?


You and the other poster who answered the same even less politely are so
allergic to linux that simply seeing the word prevents you from getting
the content out of a news post.

Someone made the point that the file command can tell whether a file uses
crlf at the end of lines. An other poster said it did not work (all he
showed is that it does not work by default on some version of solaris).
The poster who originally mentioned file and I both showed that properly
configured (with a proper "magic" database), file can indeed detect crlf.
On solaris this means updating the magic file, yes, but it is still
completely on topic.

Maybe things were not formulated in the best way, on both sides, but I
will ask you to refrain from these unjustified attacks against people
being helpful (even if those we are trying to help don't look like they
are able to understand this help).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:20 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com