LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   data file issue (https://www.linuxquestions.org/questions/linux-general-1/data-file-issue-4175441127/)

graziano1968 12-12-2012 07:57 AM

data file issue
 
Hello

I have this file

/etc/spoofdata

If I execute this ...

$ cat /etc/spoofdata
127.0.0.1

BUT if I open with pico or nano I see this
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@127.0.0.1

which could be the cause and how to remove those ^@ ?

Thank you

linosaurusroot 12-12-2012 08:12 AM

looks like binary data in the file - try "od"

druuna 12-12-2012 08:17 AM

To check what sort of file /etc/spoofdata is:
Code:

file /etc/spoofdata

graziano1968 12-12-2012 08:21 AM

I received this

/etc/spoofdata: data

I need to convert it to

/etc/spoofdata: ASCII text

how to do that ?

druuna 12-12-2012 08:26 AM

Quote:

Originally Posted by graziano1968 (Post 4847729)
I received this

/etc/spoofdata: data

This isn't a text file.

Quote:

what is wrong ?
Nothing is wrong. A lot of Unix/Linux tools are for dealing with text files and not data/binary files. cat is one of those tools.

od can give you a dump of data/binary files, strings can dump printable characters. Have a look at both man pages for details.

graziano1968 12-12-2012 08:28 AM

really lost at this point

is there any fast way to convert

/etc/spoofdata: data

to

/etc/spoofdata: ASCII text

thank you

druuna 12-12-2012 08:33 AM

Before you start tampering with that specific file you need to ask yourself why this file is a data file. Did you create it yourself? was it generated by the system?

If you created it yourself you can delete the file and create a new one using an editor (vi(m)/emacs/gedit/..).
If this file was created by the system then you shouldn't tamper with it, it has this data format for a reason.


All times are GMT -5. The time now is 10:16 AM.