Linux command
If you want to copy file using linux shell script command, using some below command, this will be helpful for you.This topic we will focus to deploy file on linux in one game. follow my shell script. You can easy do it!
Explore My Other Channel for More Cool and Valuable Insights
π Youtube Learn Tech Tipsπ Tiktok
π Facebook:- Using cp for copy file
- Using $( ) for exec Shell script
- Using if [ $# -ne 1 ] for check condition
- Using $1 for params one
- Using echo -e "\e[1;32m ........ \e[0m" for hightlight color text
# using
# echo -e "\e[1;31m ........ \e[0m" red color
# echo -e "\e[1;32m ........ \e[0m" green color
# echo -e "\e[1;33m ........ \e[0m" yellow color
# echo -e "\e[1;35m ........ \e[0m" pink color
# my path = "/home/subasa/patch_number_one/code";
# I want to copy all file on this patch to 5 linux
echo -e "\e[1;32m-------- Update patch to all linux -------- \e[0m"
echo -e "\e[1;32m + AUTHOR : zidane (huuvi168@gmail.com)\e[0m"
echo -e "\e[1;32m + LAST MODIFIED: 2015-03-09 \e[0m"
echo -e "\e[1;32m-------- ------------------------ ---------- \e[0m"
# -ne different (-ne same !=)
if [ $# -ne 1 ]
then
echo "{Usage:} sh uppatch.sh {dir-patch}"
exit 1
fi
#$1: params 1 and patch_number_one/code folder
fulldir="$1patch_number_one/code"
# exists spatch_number_one/code patch
if [ -d $fulldir ]
then
for i in 1 2 3 4 5
do
# copy all file form fulldir to server1,2,3,4,5
cp -rf $fulldir server$i
echo "UP PATCH TO server$i -> Succeed"
done
echo " ********************************** "
fi
# total files
fulldir="$1patch_number_one/"
echo "$fulldir";
cd $fulldir
# get total files
nCount=$(find . -type f | wc -l)
echo -e "Total files: \e[1;35m $nCount \e[0mhad uploaded to server!";
Thank you for reading this post. I hope you found it helpful and easy to follow. If you have any feedback or questions about
How to Copy file using linux Shell Script Command ,
please share them in the comments below. I would love to hear from you and discuss this topic further
✋✋✋✋
Webzone Tech Tips Zidane, all things tech tips web development
- I am Zidane, See you next time soon ✋✋✋✋