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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how vi effects a file 1

Status
Not open for further replies.

unixisbest

Technical User
Jul 11, 2005
28
0
0
Hi all,
I am really currios to know how could vi effect a file? I mean there is a licence file and if i open that file by using vi editor file gets corrupted . cat and pg does not? I just want to know how it could corrupt a file? vi editor does not changes date or permissions? So what would be the reason?

Any idea about this?
 
Hi,

vi is a text editor, it does not corrupt any text file.
Perhaps, yoy licence file contains some non printable characters that pg and cat does not print. These characters may disturb displaying when using vi.

try od command to display all charcters in hexa code (including non printable)of your file
Code:
od -xc /path/to/yourfile | pg
 
I regularly use vi to view files that must not be corrupted. I prefer it's navigational abilities over, for example, pg. The key thing is to ensure that you always close vi with :q! - i.e. any changes you may have inadvertantly made are not saved.

Ceci n'est pas une signature
Columb Healy
 
Or use view instead of vi - opens a file in vi but with readonly mode.


HTH,

p5wizard
 
Hi All,
Thanks for answers but my question is not with editing this file. I am only trying to find out what methods could be used to protect a licence file like this. Even i use `q!` and exit to this file it gets corrupted. There is something related with vi editor.

aau thanks for answer . Probably there is some hidden characters in the file as you say.I have used your command string but it is so complicated to findout differences.

I will make you know if i can findout something.


Thanks
 
That sounds very odd.

I agree with p5 and columb... I use view all the time and it never touches the original file, text file or not.

How about you do an od -xc of the file into /tmp/od-xc.out.before before looking at it in vi, and then od -xc again into /tmp/od-xc.out.after and then compare the two with diff. Any differences?

Annihilannic.
 
I also agree that vi never bothers a file just to view it. I have seen license files that are "branded" with the inode where they reside, so if they are copied somewhere else they become invalid.
 
Q: Does vi complain about null characters when you open the file? Does it complain about null chars again after you exit vi and reopen the file with vi?


HTH,

p5wizard
 
Is the file a plain text file or could it be binary?

do file <filename> to confirm.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Hi Mike,
You can see below how it looks like;

# file licence
licence: data

But when i edit this file it seems readable data.
 
Theres your answer it's not an ascii test file, although you may not be able to see it the file has 'other' data in it.

try strings <filename>

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
If i do strings <filename> i get what file includes same as vi editor.

Then my answer is this is a data file and when i edit and do some changes it converts to ascii text format.

So is there a way to keep it in data format even make changes?
 
What app is the license file for, it would be normal for the software house to supply the file or have it's own util to create or amend it.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Ah! So you are making changes to the file then! I thought you said you were just looking at it??

Sounds like you need some kind of hex editor perhaps?

Annihilannic.
 
Ok Mike thanks,
I am not trying to crack their file but it is really good to learned that there can created files like that in Unix. Do you know any tool or script i can create this kind of files?
 
See Annihilannic answer

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top