Chinaunix
标题:
请问有没有办法在删除链接文件的同时也删除源文件?
[打印本页]
作者:
zhouxiao_82
时间:
2008-06-02 10:33
标题:
请问有没有办法在删除链接文件的同时也删除源文件?
如题,谢谢~~~
作者:
hh9net
时间:
2008-06-02 11:34
楼上不懂别瞎说!!!!!!!!!!
作者:
Ksharp
时间:
2008-06-02 12:52
仅适用于软链接,呵呵,稍微更新了一下
#!/bin/bash
# if the file is a symbol link, remove it with the source file
if [ -e $1 ]
then
if [ -L $1 ]
then
SOURCEFILE=$(file $1|awk '{print $NF}'|cut -d\' -f1|cut -d\` -f2)
echo "Now removing $1 and its source file $SOURCEFILE..."
rm -f $1 $SOURCEFILE
else
echo "$1 is not a symbolic link file, remove cancelled."
fi
else
echo "File Not Existed!"
fi
复制代码
[
本帖最后由 Ksharp 于 2008-7-25 14:38 编辑
]
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2