[Solved] How can we take copy of a file using Bash script in Ubuntu?

| | 1 min read

This article will help you to declare and print a variable using programming basic, intermediate shell scripts and how to use Bash script to copy files in Ubuntu. Actually, Bash is very simple and flexible UNIX shell scripting language which need some permission while executing.

Here I'm going to share some tips of Bash Script. It does not intend to be an advanced document. To clear your doubts or share your information about Bash, you can contact us.

Using Bash script we can declare and print a variable using,

# declare STRING variable
STRING="Hello World"
#print variable on a screen
echo $STRING

To copy files using Bash script, we can use,

d=$(date +%m%d%y)

cp $srcdir $dstdir

#for srcfile in ${srcdir}
#    dstfile=$(basename $srcfile)
#    dstfile=${dstfile/\./${d}\.}
#   cp $srcfile $dstdir/$dstfile

Do you need more information about Bash script or commands, checkout now.