#!/bin/sh if [ ! -f "$1" ]; then echo "$0 targetfile" exit 1 fi MC=`nkf --debug "$1" 2>&1 | head -n 1` KC=`head -n 1 "$1" | od -c | head -n 2` FS=`ls -l "$1" | awk '{print $5;}'` MAC=0 UNIX=0 WIN=0 k_check1(){ for i in $KC; do if [ "$i" = "\\r" ]; then MAC=1 elif [ "$i" = "\\n" ]; then UNIX=1 fi done } k_check2(){ WIN=`expr $MAC + $UNIX` if [ "$WIN" = "2" ]; then KC="windows" elif [ "$MAC" = "1" ]; then KC="mac" elif [ "$UNIX" = "1" ]; then KC="unix" else KC="unknown" fi } m_check(){ if [ "$MC" = "Shift_JIS" ]; then MC="sjis" elif [ "$MC" = "EUC-JP" ]; then MC="euc" elif [ "$MC" = "UTF-8" ]; then MC="utf8" else MC="unknown" fi } k_check1 k_check2 m_check echo "$1 (*$MC*$KC): $FS bytes" exit 0