##
## CentOS 6.4, PostgreSQL 9.2.4 community
##
1. COPY 로드시 BOM(Byte Order Mark) 이슈로 에러가 발생 가능.
2. Linux는 SAM생성시 without BOM, Windows는 SAM생성시 with BOM이 디폴트.
3. 그래서 Windows에서 생성된 SAM을 Linux에서 COPY시 다음 에러 발생.
ERROR: invalid input syntax for integer: "1"
SQL 상태:22P02
컨텍스트:COPY tbl_bulk, line 1, column id: "1"
4. BOM만 제거해 주는 쉘이나 프로그램을 이용하여 변환하여 처리.
#!/bin/bash
#
# BOMRemover v1.0
#
# (c) 2011, Adil Aliyev
# NEATS LLC
# Baku/Azerbaijan
#
#
adilaliev@gmail.com#
function usage() {
echo "BOMRemover v1.0"
echo ""
echo "(c) 2011, Adil Aliyev"
echo ""
echo "Usage:"
echo "bomremover [-r] files..."
echo " -r Scan subdirectories."
echo ""
}
RECURSIVE_MODE=false
while getopts "rh" opt
do
case $opt in
r) RECURSIVE_MODE=true ;;
h) usage; exit 1;;
*) echo "Illegal option." ; exit 2 ;;
esac
done
FILES="$@"
if [ ! -n "$FILES" ] ; then
echo "bomremover: No file specified"
exit 1
fi
color_greenf="\033[01;32m"
color_reset="\033[0m"
if [ $RECURSIVE_MODE == true ] ; then
find . -type f | while read file
do
sed -i 's/^\xef\xbb\xbf//' "$file"
echo -e "$file\t\t\t${color_greenf}done.${color_reset}";
done
else
for i in $FILES ; do
sed -i 's/^\xef\xbb\xbf//' $i
echo -e "$i\t\t\t${color_greenf}done.${color_reset}";
done
fi
#EOF