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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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. |
| |||
| 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... |
| |||
| 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! |
| |||
| 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 |
| |||
| 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 |
| |||
| 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. |
| |||
| 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. |
| |||
| 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 |
| ||||
| 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). |
| Thread Tools | |
| Display Modes | |
|
|