Skip to content

Instantly share code, notes, and snippets.

@Tiger6688
Forked from redraiment/linux2win.sh
Created August 30, 2014 10:21
Show Gist options
  • Select an option

  • Save Tiger6688/c0e23e96d2a6f3bf33ff to your computer and use it in GitHub Desktop.

Select an option

Save Tiger6688/c0e23e96d2a6f3bf33ff to your computer and use it in GitHub Desktop.
#!/bin/sh
until [ -z $1 ]; do
unix2dos $1 2>/dev/null
iconv -f UTF-8 -t GBK $1 -o /tmp/unix2doc.tmp 2>/dev/null
if [ $? -eq 0 ]; then
mv /tmp/unix2doc.tmp $1
echo "linux2win: converting file $1 to WIN format ..."
else
rm -rf /tmp/unix2doc.tmp
echo "linux2win: converting file $1 is not Linux format ..."
fi
shift
done
#!/bin/sh
until [ -z $1 ]; do
dos2unix $1 2>/dev/null
iconv -f GBK -t UTF-8 $1 -o /tmp/win2unix.tmp 2>/dev/null
if [ $? -eq 0 ]; then
mv /tmp/win2unix.tmp $1
echo "win2linux: converting file $1 to UNIX format ..."
else
rm -rf /tmp/win2unix.tmp
echo "win2linux: converting file $1 is not WIN format ..."
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment