#!/bin/bash -
##################################################
# This scripts is uesed to unlink the file,
# and copy the linked file to local dir.
#################################################
# Function Usage
Usage () {
echo "[Usage]: $0 file.link (for single file)" >&2
echo "[Usage]: $0 * (for all files)" >&2
}
# Function UnlinkFile
UnlinkFile () {
if test -h $1
then
cp $1 ${1}.old
unlink $1
mv ${1}.old $1
printf "[Info]: %20s unlink done!!\n" $1
else
printf "[Info]: %20s isn't a link file!!\n" $1
fi
}
file=
verbose=
quiet=
long=
if $# -eq 0
then
echo "[Warning] Please add some file names or (*) ." >&2
echo "[Warning] Please refer to below comments for more infomation." >&2
Usage
fi
# Main Function
while [ $# -gt 0 ]
do
case $1 in
-f) file=$2
shift 2
;;
-v) verbose=ture
quiet=
shift
;;
-q) quiet=ture
verbose=
shift
;;
-h | -help) Usage
exit 1
;;
--) shift
#break
;;
-*) echo $0:$1 : unrecognised option >&2
shift
;;
*) UnlinkFile $1
shift
;;
esac
done
#echo $*
#for i in $*
#do
# if test -h $i
# then
# cp $i ${i}_1
# unlink $i
# mv ${i}_1 $i
# printf "[Info]: %20s unlink done!!\n" $i
# else
#
# printf "[Info]: %20s isn't a link file!!\n" $i
# fi
#done
#while [ $# -gt 0 ]
#do
# if test -h $i
# then
# ehco "$i"
# mv $i ${i}_1
# unlink $i
# mv ${i}_1 $i
# else
# echo "$i isn't a link!!"
# fi
# shift
#done