Thursday 27 September 2012

Linux: Converting File Types ( MIME)


Working on difference between   files :
vimdiff     httpserver_directory.txt  Entire_productsxml.txt
Commands used for Comparision:
1.vimdiff     httpserver_directory.ndi  Entire_productsxml.txt   
 not  working as  MIME types are different. One is xml  and the other is text file.

2.I needed  iconv  command here  to conver the MIME types   from  text/xml   to ascii/xml
a. Do these files have  same character sets?
b.First see the character sets  of each file :
Command :
file -i *
 [root@blr-elorhel4x86 ndtrack]# file -i *
Entire_productsxml.ndi:   text/plain; charset=us-ascii
Entire_productsxml.txt:   application/x-empty
httpserver_directory.ndi:
httpsever_ouionly.ndi:    text/plain; charset=us-ascii
ndtrack.ini:              text/plain; charset=utf-8
ndtrack.sh:               application/x-shellscript
run.sh:                   application/x-shellscript
c.To convert from one  format  to other format:
Command: I will use it later, because I need to  some   text parsing.
iconv -f FROM-ENCODING -t TO-ENCODING file.txt
d.How  am I doing text parsing?
I am using perl  command line  to act on to file:
Re-learn : perl -nle '$_ =~ s/^(\w+)$/$&/g ; print  $_' Entire_productsxml.ndi    
Beginning spaces in the line are not replaced. Simple, but I don’t know.

No comments:

Post a Comment

Tweets by @sriramperumalla