echo "Enter File name to copy \c"
read f1
echo "Enter FIle name \c "
read f2
if [ -f $f1 ]
then
cp $f1 $f2
else
echo "$f1 does not exist"
fi
我试过没有争论所以请建议我怎么做?
答案 0 :(得分:0)
尝试此操作只会复制您有权使用的文件: -
destination_Path="/Users/Home/Desktop/test"
b=~/Desktop/copyPermission.txt
if [ ! -f $b ]
then
touch $b
fi
a=`ls -l`
e="-----w--w-"
echo "\n$a" | sed '1d' > $b
g=`pwd`
while read line
do
d=`echo "$line" | awk '{print $1}'`
if [ $e != $d ]
then
r=`echo "$line" | awk '{print $9}'`
echo "Can have copy permission $g/$r"
{
cp $g/$r "$destination_Path" && echo "copied successfully"
} || {
echo "cannot copy due to some error"
}
#else
#r=`echo "$line" | awk '{print $9}'`
#echo "Cannot have copy permission $r"
fi
done <"$b"