![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| total number of files which have "aaa" in files whose names are File*_bbb* | sudheshnaiyer | UNIX for Dummies Questions & Answers | 1 | 08-16-2007 11:34 AM |
| Maximum input file size in "Diff" Command | Neeraja | UNIX for Dummies Questions & Answers | 1 | 01-17-2007 06:09 AM |
| ps command returns a "?" | jxh461 | UNIX for Dummies Questions & Answers | 6 | 09-23-2006 04:15 PM |
| pthread_create returns "operation not permitted" if I try to link static? | Micky | High Level Programming | 1 | 07-21-2005 04:58 AM |
| reformat the output from "diff" command | CamTu | Shell Programming and Scripting | 5 | 03-01-2005 06:54 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I have a c-source file that is evidently seen by unix as a binary file. When doing a diff between it and older versions with substantial differences, diff will only return "files differ".
I have tried cat-ing the file to another file; tried using the "-h" on the diff; I have tried ftp-ing it back and forth as ascii; I have played with chmod; I have tried using dos2unix... no matter what I do I can't get Unix to see the file as a text file. Anybody seen this before... and have a solution? |
| Forum Sponsor | ||
|
|
|
|||
|
Sounds like you've got gremlins. You can use some commands illustrated in that thread to strip out the offending characters.
It's not UNIX that's being stubborn about this, just diff. UNIX has no concept of "text file", everything's just data. Note that, if it can't diff, it probably can't compile either. Most compilers throw up on high ASCII. Which file have you been doing all the pounding on? Maybye you're fixing the wrong one, and the gremlin's in the other? |
|
|||
|
What does 'file' say? Also, you could write a small C program to filter any 'gremlin' characters, visible or not.
Code:
$ file Clean.c
Clean.c: ASCII C program text
$ cat Clean.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
main( int argc, char *argv[] )
{
char c;
while( (read( STDIN_FILENO , &c , sizeof( char ) )) > 0 )
if (isprint( c )||isspace(c))
printf("%c",c);
return 0;
}
|
|
|||
|
Quote:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> main() { FILE *fpInput, *fdOutput; char c; fdOutput = fopen("mainout.c", "w"); fpInput = fopen("main.c", "r"); while (fread(&c, sizeof(char), 1, fpInput) > 0) { if(isprint(c) || isspace(c)) fprintf(fdOutput,"%c", c); } fclose (fpInput); fclose (fdOutput); } |
|
|||
|
Glad the problem is solved. That they're the same length is very odd -- the only way that program can change the file is by excluding bytes! Thus I have found an exception to what I previously thought was a rule, that UNIX does not differentiate between text and binary files. What UNIX are you using?
|
|||
| Google UNIX.COM |