Write a shell script to copy a file from one directory to another?



echo “enter a file”
read fname
if [ - f “ $fname” ]
then
echo “ file $fname exist”
else
echo “file not exist”
exit
fi
echo “enter a directory”
read dn
if [ -d “ $dn” ]
then
cp $fname $dn
echo “ $fname copied to $dn”
else
echo “directory $dn does not exists”
fi


OUTPUT:

enter a file
prime.sh
file prime.sh exist

enter a directory
dir
prime.sh copied to dir

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart