$dir is fetched from a property file (prop.txt) which stores its value
dir=/opt/data
Now the problem is another dir1 comes into picture. I only want to add dir1=<path> in the propertyfile and dont want to change the actual shell script. Is it possible?
You want to define a variable dir1=something in your prop.txt file ON TOP of the existing dir definition, both pointing to different locations. Then you want to cpdir 's contents to an archive directory, and cpdir1 's contents to another archive. All this without modifying your above code snippet. Is that correct?
I'm afraid this won't work. You'll need to inform the code that dir1 exists and shoud be used, and, for two actions you'll need two commands (mayhap in a loop, other story).
Please be aware that recursively copying a source directory into an own subdirectory may lead to an infinite loop. Fortunately, this cp is quite clever:
cp: cannot copy a directory, �.�, into itself, �archive/.�