Martini002 Martini002 - 1 year ago 90
Bash Question

How to remove accents from a file using a cron job?

I have a .sh file that convert accents into unaccent chars using iconv, so I have this file:


Running the .sh manually from the command line:

iconv -f utf8 -t ascii//TRANSLIT "$FUT2" > "$FUT"

I get in the file:


Thats nice, but when I run it from the cron, using webmin and setting up a scheduled cron job, then i get:


and, if I use sed

Running the .sh manually from the command line:

sed -e 's/[á]/a/g;s/[é]/e/g;s/[í]/i/g;s/[ó]/o/g;s/[ú]/u/g' "$FUT2" > "$FUT"


Running from webmin


The .sh its UTF-8 without BOM

So any idea how to fix it or any other way how to replace the accents?

Answer Source

Did you try to set the var LANG=en_US.UTF-8 in the crontab command?

0 5 * * 1 LANG=en_US.UTF-8 iconv -f utf8 -t ascii//TRANSLIT "file1" > "file2"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download