Re: Migrating file from the old gnumeric version to the current version



On Tue, 1 Mar 2005 15:06:25 -0500, Daniel Savard
<daniel savard gmail com> wrote:
(...)
I wrote a small shell script to insert the encoding specification, here it is:
------------------------------------------------------------------------
#!/bin/bash

my_file=$1
tmp=/tmp/conv_$$.gnumeric

if [ -f $tmp ]; then
  rm -f $tmp
fi

type=`file "$my_file" | cut -d: -f2 | cut -d\  -f2`
if [ "$type" != "gzip" ]
then
  echo "$my_file"
  echo "Incompatible file format."

     exit 1
# Or put the next if-then-else construct inside a else clause here
# I removed the exit accidentally when copying. Sorry.

fi

if [ -w "$my_file" ]; then
  gzcat "$my_file" | sed s/'<?xml version="1.0"?>'/'<?xml
version="1.0" encoding="UTF-8"?>'/ | gzip > $tmp
  mv $tmp "$my_file"
fi

exit 0
----------------------------------------------------------------------------------------------------



-- 
-----------------
Daniel Savard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]