Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regd the format of the file

Status
Not open for further replies.

123jk

Programmer
Mar 22, 2001
7
0
0
IN
Hi,

How do i check the format of the file.
I need to convert the ascii text files to unix format. That can be done through dos2unix command. But before conversion i actually need to check if the file is in dos format.

Is there a command to check the file format?

Regards
jaya
 
You can check whether the file contains any ^M characters (DOS end-of-line chars) in vi or using grep (though the latter will only return a blank line if it does find anything, nothing if it doesn't), but I would question why you need to check this as if the file isn't in DOS format, dos2unix won't change anything anyway. Does this help?
 
Try the
Code:
file
command. Ken, I think the reason 123jk wants to check the file first is in case it is a binary file which dos2unix would corrupt if it happened to have a crlf pair in it.

Hope this helps. CaKiwi
 
CaKiwi - thanks, I'd not thought of that possibility, good catch. All that cricket no doubt! ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top