I have an interesting requirement. I have declaried an array like :-
arr=`find . ! -name "." | xargs -I {} echo {} | cut -c 2-${#}`
Then i will try to access the array elements like :-
i=0
for i in ${arr}; do
Here comes the confusions, the array elements are basically dir and files stored as strings
something like :-
"/etc/src/esr/11.2/aix" - This is a dir
"/etc/src/esr/11.2/aix/defalut.cfg" - This is a file inside the above dir
"/etc/src/esr/11.2/fn" - This is a dir
"/etc/src/esr/11.2/hpux/fn95anes.cfg" - This is a file inside the above dir
I want to create the same directories and files(with contents in the file) in destination as well.
That means i need to check whether the array element is dir/file then accordingly i need to create directories inside that i need to create files respectively
I did something like
if [[ -d $DIR/$i ]] ; then (DIR and DEST are predefined location)
mkdir $DIR/$i $DEST/$i
elif [[ -f $DIR/$i ]] ; then
cp $DIR/$i $DEST/$i
But it is not properly creating files inside directories, please help me out
Thanks in advance
Renjesh