유용한 쉘 스크립트
2016. 10. 20. 21:02ㆍ99. 정리전 - IT/13. Unix 얇팍지식
#!/bin/bash
#sh trans-name.sh YSL1
#sh trans-name.sh YSL2
ARG0="$0"
while [ -h "$ARG0" ]; do
ls=`ls -ld "$ARG0"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
ARG0="$link"
else
ARG0="`dirname $ARG0`/$link"
fi
done
DIRNAME="`dirname $ARG0`"
PROGRAM="`basename $ARG0`"
FILE_NAME_CSV="YSL-Teacher-Guide-Resource-List-$1-1.csv"
IFS_OLD=$IFS
IFS=,
while read A B C D E F G H I
do
DIR_SOURSE="$A/$B"
DIR_TARGET="$D/$E/$F/$G"
if [ ! -d $DIR_TARGET ]; then
mkdir -p $DIR_TARGET
fi
cp "$DIR_SOURSE/$C" "$DIR_TARGET/$H"
done < $FILE_NAME_CSV
IFS=$IFS_OLD