Need to check the file formats


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to check the file formats
# 1  
Old 07-21-2014
Need to check the file formats

Hi,

I want to check the incoming files whether the file is Mac file or dos/windows file in unix shell script.

Sometimes client is posting Mac file and sometimes it is dos file. Could you please help me how to determine/check whether the file is Mac or dos.

Help in advance


Thanks
# 2  
Old 07-21-2014
The file command should show you what type of file it is.
# 3  
Old 07-21-2014
Hi,

Yes u r right if we can use file <filename> it will display the format of file. Requirement is to check the files whether the file is in Mac or dos? If file is Mac it will display the message it is Mac file. If file is dos it will display the file it is dos file.


thanks in advance
# 4  
Old 07-21-2014
So, is this solved? You can for example grep the output of file and decide what you will do in you shell script.
# 5  
Old 07-21-2014
What is your definition of a Mac file?

What is your definition of a DOS/Windows file?

Are you trying to convert from a Windows code set to UTF-8 or UTF-8 to a Windows code set?

Are you trying to change DOS/Windows <carriage-return><newline> line terminators in a text file to Mac <newline> line terminators or Mac <newline> line terminators in a text file to DOS/Windows <carriage-return><newline> line terminators?

Are you working with text files?

Are you working with Microsoft Word files?

Are you working with Excel spreadsheet files?

Are you hoping to take a DOS/Windows binary file and execute it on a Mac or take a Mac binary file and execute it on a DOS/Windows system?
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Parse apache log file with three different time formats

Hi, I want to parse below file and Write a function to extract the logs between two given timestamp. Apache (Unix) Log Samples - MonitorWare The challenge here is there are three date and time format. First :- 07/Mar/2004:16:05:49 Second :- Sun Mar 7 16:02:00 2004 Third :- 29-Mar... (6 Replies)
Discussion started by: sahil_shine
6 Replies

2. Shell Programming and Scripting

Using awk to parse a file with mixed formats in columns

Greetings I have a file formatted like this: rhino grey weight=1003;height=231;class=heaviest;histology=9,0,0,8 bird white weight=23;height=88;class=light;histology=7,5,1,0,0 turtle green weight=40;height=9;class=light;histology=6,0,2,0... (2 Replies)
Discussion started by: Twinklefingers
2 Replies

3. UNIX for Dummies Questions & Answers

What are the executable file formats in Solaris and Linux?

we all knew that .exe files are the executable file formats in windows....... Similarly, what are the executable file formats in solaris and linux ........ please tell me:D Thanks in Advance. (2 Replies)
Discussion started by: vamshigvk475
2 Replies

4. Shell Programming and Scripting

Removing formats (bold) from UNIX file

Hi , Could you please guide me how to remove formatting (bold text) in a unix file? vi editor showing like this... ^ Cat command showing like this... tl21ss01 tl21ss02 tl21ss03 (6 Replies)
Discussion started by: suresh3566
6 Replies

5. Shell Programming and Scripting

BASH script outputting strange file formats

Hi I am very new to using BASH, but I have a problem with a piece of script that I have been working on. Basically the script goes through a mailbox file looking at particular aspects of the file, for example how many spamwords there are email address etc. It does this pretty well except for an... (13 Replies)
Discussion started by: 9aza
13 Replies

6. Shell Programming and Scripting

Extracting data from a log file with date formats

Hello, I have a log file for the year, which contains lines starting with the data in the format of YYYY-MM-DD. I need to get all the lines that contain the DD being 04, how would I do this? I tried using grep "*-*04" but it didn't work. Any quick one liners I should know about? Thank you. (2 Replies)
Discussion started by: cpickering
2 Replies

7. Shell Programming and Scripting

ksh script to create a generic csv file from different source formats

Hi all, I have a requirement to create a "superset" file out of a number of different sources with some different and some same columns. We intend to have a manually updateable SuperSetCols.csv which would look like "ColA","ColB","ColC","ColD","ColE","ColF","ColG" so someday we may add... (3 Replies)
Discussion started by: Leedor
3 Replies
Login or Register to Ask a Question