How to convert a text file from Shift JIS to UTF-8 and back from the terminal

In order to make this conversion I have to use a text editor. This is tedious. Is there an easier way to do it, like some program I can run from the Linux or OS X terminal?


To convert from Shift JIS to UTF-8 on linux just do:

iconv -f SHIFT-JIS -t UTF-8 <infile> > <outfile>

and to go the other way just reverse the arguments:

iconv -f UTF-8 -t SHIFT-JIS <infile> > <outfile>

I don't know OSX but it may well have the iconv command as well, in which case something similar should work.