Operating System - HP-UX
1832096 Members
2802 Online
110038 Solutions
New Discussion

Re: can I use 'vi' to edit the file with the suffix 'bin'??

 
xxl_1
Frequent Advisor

can I use 'vi' to edit the file with the suffix 'bin'??

ask a simple problem:

how I can edit the file with the suffix 'bin'?
15 REPLIES 15
Vibhor Kumar Agarwal
Esteemed Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

Yes you can but the ouput will not be understanable.
Vibhor Kumar Agarwal
Arunvijai_4
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

If its a data file or ascii file, you can edit with "vi". If its a binary file, you cant do anything with "vi". Try # file and check the type before opening in "vi"

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
RAC_1
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

what does file "your_file" say??
vi is not helpful if it is a binary file.
There is no substitute to HARDWORK
Muthukumar_5
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

Check out file information as,

# file

It has to be in text format to edit it. If it is a object file then it will not be in readable format.

If it is a text formatted one then use perl / sed to edit.

hth.
Easy to suggest when don't know about the problem!
Joseph Loo
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

hi,

do this first:

# file
if it is a text/ascii file, editing will make sense, else quite pointless.

regards.
(p.s. please remember to assign points.)
what you do not see does not mean you should not believe
Orhan Biyiklioglu
Respected Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

If you really need to edit a binary file try using hexedit http://hpux.connect.org.uk/hppd/hpux/Development/Tools/hexedit-1.2.10/

hth
Kryno Bosman
Advisor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

Check with file if the file is (read/edit)able. If it is you can try with vi. Otherwise, you can't.
Simplicity is too difficult for idiots like you and me...
xxl_1
Frequent Advisor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

I type the command:
#file cluma
cluma :command text( this is output)


can I edit it with "vi"?
MarkSyder
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

Yes you can.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
rariasn
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??


Hi,
Check out file information as,

# file file_name
# strings file_name

s2
Wim Rombauts
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

You can edit any textfiel with vi, whatever the name or extensions. Of course, when the file is not a textfile, vi can have difficulty reading it, but you can't trust the extension to tell you what type of file it is.
Extensions on unix don't really mean a thing. They are just a couple of characters that are part of te filename, just like any other character in the filename.
Filename extensions are only a way for humans to put something in the filename that is linked to the type of content in the file, but computers have no use for it at all.
To find out what is really in a file, don't look at the extension. Use the "file" and "strings" commands that are already referenced above.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

You can also use the od if you are facing some problems with vi.
Vibhor Kumar Agarwal
Andrew Merritt_2
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

If it does turn out to be a binary file (i.e. one with control characters), you can use 'vis' and 'inv' to make it editable with vi.

E.g.

vis filename >tmpfile
vi tmpfile
inv tmpfile >filename

(See 'man inv' for the character substitutions done.)

Andrew
Ralph Grothe
Honored Contributor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

Filenames are meaningless on Unix systems.
So one cannot say beforehand if a file is a binary just from its name
(though there are sensible naming conventions).
A better indicator of a file's content type is its magic number.
The "file" command that you used will read that and tell you from looking up a table what type it is if it found a match.
Since it tells you "command text" I think it's safe to open the file with vi.
Madness, thy name is system administration
Shweta_3
Occasional Advisor

Re: can I use 'vi' to edit the file with the suffix 'bin'??

The suffix "bin" may or may not be an indicator of the type of file.
The command
"file " is a good way to see what kind of file is it. It may be an ascii text file/some kind of shell script executable/or a binary format etc
e.g
>file /usr/bin/ls
/usr/bin/ls: PA-RISC1.1 shared executable dynamically linked

In case it is an executable (which is what I assume you are looking for), you may get limited information about the file using commands like "strings" !!

However to edit the file, you will require to have the source for the binary, and only that you may edit and re-build the binary.