Technical Solution
[Solved] How can we take copy of a file using Bash script in Ubuntu?
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,
#!/bin/bash
# declare STRING variable
STRING="Hello World"
#print variable on a screen
echo $STRING
To copy files using Bash script, we can use,
#!/bin/bash
srcdir="~/Desktop/bash_script"
dstdir="~/Desktop/bash_new/"
d=$(date +%m%d%y)
srcfile="hello_world.sh"
cp $srcdir $dstdir
#for srcfile in ${srcdir}
#do
# dstfile=$(basename $srcfile)
# dstfile=${dstfile/\./${d}\.}
# cp $srcfile $dstdir/$dstfile
#done
Do you need more information about Bash script or commands, checkout now.