-2
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

我试过没有争论,所以请建议我怎么做?

4

1 回答 1

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"
于 2013-09-26T05:50:54.867 回答