如何在linux中编写shell脚本程序,使用命令行参数将源文件复制到目标文件

如何在linux中编写shell脚本程序,使用命令行参数将源文件复制到目标文件,linux,unix,Linux,Unix,我已经尝试了,没有任何争论,所以请建议我怎么做?试试这个,它只会复制您有权限的文件:- echo "Enter File name to copy \c" read f1 echo "Enter FIle name \c " read f2 if [ -f $f1 ] then cp $f1 $f2

我已经尝试了,没有任何争论,所以请建议我怎么做?

试试这个,它只会复制您有权限的文件:-

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
别名mycopy=cp。。不知道你想做什么。cp已经接受命令行参数。
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"