ghong6003的个人空间 https://blog.eetop.cn/1430538 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

unlink_and_cp.sh

已有 446 次阅读| 2018-3-6 22:15 |个人分类:Shell|系统分类:芯片设计

#!/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



点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 1

    关注
  • 3

    粉丝
  • 0

    好友
  • 2

    获赞
  • 1

    评论
  • 1539

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-26 07:25 , Processed in 0.032926 second(s), 15 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部