home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!nwnexus!Celestial.COM!bill
- From: bill@Celestial.COM (Bill Campbell)
- Subject: Re: How to tell if you have an ASCII file
- Organization: Celestial Software, Mercer Island, WA
- Distribution: usa
- Date: Sat, 26 Dec 1992 17:02:53 GMT
- Message-ID: <1992Dec26.170253.10375@Celestial.COM>
- References: <1992Dec22.152123.5852@Cadence.COM>
- Keywords: ASCII
- Lines: 22
-
- In <1992Dec22.152123.5852@Cadence.COM> dew@rocky.cadence.com (Dave Wilson) writes:
-
- :I would like to be able to quickly tell if the file I am opening is ASCII text
- :or some binary executable or data file. Is there any way of foolproof way of doing this?
-
- In perl you can use the -T test:
- if (-T 'filename') {
- print "is text";
- }
- else {
- print "not text";
- }
-
- This works well, but might be fooled by a text file that had
- non-ascii data (control codes imbedded in strings).
-
- Bill
- --
- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software
- UUCP: ...!thebes!camco!bill 6641 East Mercer Way
- uunet!camco!bill Mercer Island, WA 98040; (206) 947-5591
- SPEED COSTS MONEY -- HOW FAST DO YOU WANT TO GO?
-